diff --git a/packages/serverpod/lib/src/database/columns.dart b/packages/serverpod/lib/src/database/columns.dart index 182188a7ef..96a428f5d0 100644 --- a/packages/serverpod/lib/src/database/columns.dart +++ b/packages/serverpod/lib/src/database/columns.dart @@ -27,7 +27,7 @@ abstract class Column { @override String toString() { - return '${table.queryPrefix}."$_columnName"'; + return '"${table.queryPrefix}"."$_columnName"'; } } diff --git a/packages/serverpod/lib/src/database/database_query.dart b/packages/serverpod/lib/src/database/database_query.dart index f7032a2134..14ebd3df50 100644 --- a/packages/serverpod/lib/src/database/database_query.dart +++ b/packages/serverpod/lib/src/database/database_query.dart @@ -474,7 +474,7 @@ String _joinStatementFromJoinContexts( joinStatement += ' "${tableRelation.lastForeignTableName}" AS'; } - joinStatement += ' ${tableRelation.relationQueryAlias} ' + joinStatement += ' "${tableRelation.relationQueryAlias}" ' 'ON ${tableRelation.lastJoiningField} '; if (!joinContext.subQuery) { @@ -495,7 +495,7 @@ _UsingQuery _usingQueryFromJoinContexts( for (var joinContext in joinContexts.values) { var tableRelation = joinContext.tableRelation; usingStatements.add( - '"${tableRelation.lastForeignTableName}" AS ${tableRelation.relationQueryAlias}'); + '"${tableRelation.lastForeignTableName}" AS "${tableRelation.relationQueryAlias}"'); whereStatements.add( '${tableRelation.lastJoiningField} = ${tableRelation.lastJoiningForeignField}'); } diff --git a/packages/serverpod/lib/src/database/table_relation.dart b/packages/serverpod/lib/src/database/table_relation.dart index 12f1ce1181..3bcf512fac 100644 --- a/packages/serverpod/lib/src/database/table_relation.dart +++ b/packages/serverpod/lib/src/database/table_relation.dart @@ -35,12 +35,12 @@ class TableRelation { /// Name of the last field to be joined. String get lastJoiningField { - return '${_fromRelationQueryAlias()}."${_tableRelationEntries.last.field.columnName}"'; + return '"${_fromRelationQueryAlias()}"."${_tableRelationEntries.last.field.columnName}"'; } /// Name of the last foreign field to be joined. String get lastJoiningForeignField { - return '${_buildRelationQueryAlias()}."${_tableRelationEntries.last.foreignField.columnName}"'; + return '"${_buildRelationQueryAlias()}"."${_tableRelationEntries.last.foreignField.columnName}"'; } /// Name of the last foreign field to be joined as query alias. diff --git a/packages/serverpod/test/database/columns/column_bool_test.dart b/packages/serverpod/test/database/columns/column_bool_test.dart index 535042fe57..759212d260 100644 --- a/packages/serverpod/test/database/columns/column_bool_test.dart +++ b/packages/serverpod/test/database/columns/column_bool_test.dart @@ -9,7 +9,7 @@ void main() { test( 'when toString is called then column name withing double quotes is returned.', () { - expect(column.toString(), 'test."$columnName"'); + expect(column.toString(), '"test"."$columnName"'); }); test('when columnName getter is called then column name is returned.', () { diff --git a/packages/serverpod/test/database/columns/column_byte_data_test.dart b/packages/serverpod/test/database/columns/column_byte_data_test.dart index 6033b25445..0869a4915e 100644 --- a/packages/serverpod/test/database/columns/column_byte_data_test.dart +++ b/packages/serverpod/test/database/columns/column_byte_data_test.dart @@ -11,7 +11,7 @@ void main() { test( 'when toString is called then column name withing double quotes is returned.', () { - expect(column.toString(), 'test."$columnName"'); + expect(column.toString(), '"test"."$columnName"'); }); test('when columnName getter is called then column name is returned.', () { diff --git a/packages/serverpod/test/database/columns/column_date_time_test.dart b/packages/serverpod/test/database/columns/column_date_time_test.dart index 5d4ffb51b4..6d0f6c3801 100644 --- a/packages/serverpod/test/database/columns/column_date_time_test.dart +++ b/packages/serverpod/test/database/columns/column_date_time_test.dart @@ -9,7 +9,7 @@ void main() { test( 'when toString is called then column name withing double quotes is returned.', () { - expect(column.toString(), 'test."$columnName"'); + expect(column.toString(), '"test"."$columnName"'); }); test('when columnName getter is called then column name is returned.', () { diff --git a/packages/serverpod/test/database/columns/column_double_test.dart b/packages/serverpod/test/database/columns/column_double_test.dart index 4ba91a064d..3266f88778 100644 --- a/packages/serverpod/test/database/columns/column_double_test.dart +++ b/packages/serverpod/test/database/columns/column_double_test.dart @@ -9,7 +9,7 @@ void main() { test( 'when toString is called then column name withing double quotes is returned.', () { - expect(column.toString(), 'test."$columnName"'); + expect(column.toString(), '"test"."$columnName"'); }); test('when columnName getter is called then column name is returned.', () { diff --git a/packages/serverpod/test/database/columns/column_duration_test.dart b/packages/serverpod/test/database/columns/column_duration_test.dart index d2c6addbb5..8b7f07f192 100644 --- a/packages/serverpod/test/database/columns/column_duration_test.dart +++ b/packages/serverpod/test/database/columns/column_duration_test.dart @@ -9,7 +9,7 @@ void main() { test( 'when toString is called then column name withing double quotes is returned.', () { - expect(column.toString(), 'test."$columnName"'); + expect(column.toString(), '"test"."$columnName"'); }); test('when columnName getter is called then column name is returned.', () { diff --git a/packages/serverpod/test/database/columns/column_enum_test.dart b/packages/serverpod/test/database/columns/column_enum_test.dart index 027accede3..574e7b1cd7 100644 --- a/packages/serverpod/test/database/columns/column_enum_test.dart +++ b/packages/serverpod/test/database/columns/column_enum_test.dart @@ -15,7 +15,7 @@ void main() { test( 'when toString is called then column name withing double quotes is returned.', () { - expect(column.toString(), 'test."$columnName"'); + expect(column.toString(), '"test"."$columnName"'); }); test('when columnName getter is called then column name is returned.', () { diff --git a/packages/serverpod/test/database/columns/column_int_test.dart b/packages/serverpod/test/database/columns/column_int_test.dart index 38c194951c..d682e415c8 100644 --- a/packages/serverpod/test/database/columns/column_int_test.dart +++ b/packages/serverpod/test/database/columns/column_int_test.dart @@ -9,7 +9,7 @@ void main() { test( 'when toString is called then column name withing double quotes is returned.', () { - expect(column.toString(), 'test."$columnName"'); + expect(column.toString(), '"test"."$columnName"'); }); test('when columnName getter is called then column name is returned.', () { diff --git a/packages/serverpod/test/database/columns/column_serializable_test.dart b/packages/serverpod/test/database/columns/column_serializable_test.dart index 737981fdb4..f6c5096155 100644 --- a/packages/serverpod/test/database/columns/column_serializable_test.dart +++ b/packages/serverpod/test/database/columns/column_serializable_test.dart @@ -9,7 +9,7 @@ void main() { test( 'when toString is called then column name withing double quotes is returned.', () { - expect(column.toString(), 'test."$columnName"'); + expect(column.toString(), '"test"."$columnName"'); }); test('when columnName getter is called then column name is returned.', () { diff --git a/packages/serverpod/test/database/columns/column_string_test.dart b/packages/serverpod/test/database/columns/column_string_test.dart index 0e6e5020b7..6858b19e83 100644 --- a/packages/serverpod/test/database/columns/column_string_test.dart +++ b/packages/serverpod/test/database/columns/column_string_test.dart @@ -9,7 +9,7 @@ void main() { test( 'when toString is called then column name withing double quotes is returned.', () { - expect(column.toString(), 'test."$columnName"'); + expect(column.toString(), '"test"."$columnName"'); }); test('when columnName getter is called then column name is returned.', () { diff --git a/packages/serverpod/test/database/columns/column_uuid_test.dart b/packages/serverpod/test/database/columns/column_uuid_test.dart index 224a05fa10..b432f1eff2 100644 --- a/packages/serverpod/test/database/columns/column_uuid_test.dart +++ b/packages/serverpod/test/database/columns/column_uuid_test.dart @@ -9,7 +9,7 @@ void main() { test( 'when toString is called then column name withing double quotes is returned.', () { - expect(column.toString(), 'test."$columnName"'); + expect(column.toString(), '"test"."$columnName"'); }); test('when columnName getter is called then column name is returned.', () { diff --git a/packages/serverpod/test/database/database_query_test.dart b/packages/serverpod/test/database/database_query_test.dart index 671c258e98..423b4536bf 100644 --- a/packages/serverpod/test/database/database_query_test.dart +++ b/packages/serverpod/test/database/database_query_test.dart @@ -81,7 +81,7 @@ void main() { test('when default initialized then build outputs a valid SQL query.', () { var query = SelectQueryBuilder(table: citizenTable).build(); - expect(query, 'SELECT citizen."id" AS "citizen.id" FROM "citizen"'); + expect(query, 'SELECT "citizen"."id" AS "citizen.id" FROM "citizen"'); }); test('when query with specific fields is built then output selects fields.', @@ -96,7 +96,7 @@ void main() { .build(); expect(query, - 'SELECT citizen."id" AS "citizen.id", citizen."name" AS "citizen.name", citizen."age" AS "citizen.age" FROM "citizen"'); + 'SELECT "citizen"."id" AS "citizen.id", "citizen"."name" AS "citizen.name", "citizen"."age" AS "citizen.age" FROM "citizen"'); }); test( @@ -107,7 +107,7 @@ void main() { .build(); expect(query, - 'SELECT citizen."id" AS "citizen.id" FROM "citizen" WHERE "test"=@test'); + 'SELECT "citizen"."id" AS "citizen.id" FROM "citizen" WHERE "test"=@test'); }); test( @@ -122,7 +122,7 @@ void main() { .build(); expect(query, - 'SELECT citizen."id" AS "citizen.id" FROM "citizen" WHERE (TRUE = TRUE AND FALSE = FALSE)'); + 'SELECT "citizen"."id" AS "citizen.id" FROM "citizen" WHERE (TRUE = TRUE AND FALSE = FALSE)'); }); test( @@ -137,7 +137,7 @@ void main() { SelectQueryBuilder(table: citizenTable).withOrderBy([order]).build(); expect(query, - 'SELECT citizen."id" AS "citizen.id" FROM "citizen" ORDER BY citizen."id"'); + 'SELECT "citizen"."id" AS "citizen.id" FROM "citizen" ORDER BY "citizen"."id"'); }); test( @@ -162,7 +162,7 @@ void main() { SelectQueryBuilder(table: citizenTable).withOrderBy(orders).build(); expect(query, - 'SELECT citizen."id" AS "citizen.id" FROM "citizen" ORDER BY citizen."id", citizen."name" DESC, citizen."age"'); + 'SELECT "citizen"."id" AS "citizen.id" FROM "citizen" ORDER BY "citizen"."id", "citizen"."name" DESC, "citizen"."age"'); }); test( @@ -182,7 +182,7 @@ void main() { expect( query, - 'SELECT citizen."id" AS "citizen.id" FROM "citizen" LEFT JOIN "citizen" AS citizen_friends_citizen ON citizen."id" = citizen_friends_citizen."id" GROUP BY "citizen.id" ORDER BY COUNT(citizen_friends_citizen."id")', + 'SELECT "citizen"."id" AS "citizen.id" FROM "citizen" LEFT JOIN "citizen" AS "citizen_friends_citizen" ON "citizen"."id" = "citizen_friends_citizen"."id" GROUP BY "citizen.id" ORDER BY COUNT("citizen_friends_citizen"."id")', ); }); @@ -202,7 +202,7 @@ void main() { SelectQueryBuilder(table: citizenTable).withOrderBy([order]).build(); expect(query, - 'WITH citizen_friends_citizen AS (SELECT citizen."id" AS "citizen.id" FROM "citizen" WHERE citizen."id" = 5) SELECT citizen."id" AS "citizen.id" FROM "citizen" LEFT JOIN citizen_friends_citizen ON citizen."id" = citizen_friends_citizen."citizen.id" GROUP BY "citizen.id" ORDER BY COUNT(citizen_friends_citizen."citizen.id")'); + 'WITH citizen_friends_citizen AS (SELECT "citizen"."id" AS "citizen.id" FROM "citizen" WHERE "citizen"."id" = 5) SELECT "citizen"."id" AS "citizen.id" FROM "citizen" LEFT JOIN "citizen_friends_citizen" ON "citizen"."id" = "citizen_friends_citizen"."citizen.id" GROUP BY "citizen.id" ORDER BY COUNT("citizen_friends_citizen"."citizen.id")'); }); test( @@ -232,8 +232,8 @@ void main() { test('when query with limit is built then output is query with limit.', () { var query = SelectQueryBuilder(table: citizenTable).withLimit(10).build(); - expect( - query, 'SELECT citizen."id" AS "citizen.id" FROM "citizen" LIMIT 10'); + expect(query, + 'SELECT "citizen"."id" AS "citizen.id" FROM "citizen" LIMIT 10'); }); test('when query with offset is built then output is query with offset.', @@ -242,7 +242,7 @@ void main() { SelectQueryBuilder(table: citizenTable).withOffset(10).build(); expect(query, - 'SELECT citizen."id" AS "citizen.id" FROM "citizen" OFFSET 10'); + 'SELECT "citizen"."id" AS "citizen.id" FROM "citizen" OFFSET 10'); }); test( @@ -264,7 +264,7 @@ void main() { .build(); expect(query, - 'SELECT citizen."id" AS "citizen.id" FROM "citizen" LEFT JOIN "company" AS citizen_company_company ON citizen."companyId" = citizen_company_company."id" WHERE citizen_company_company."name" = \'Serverpod\''); + 'SELECT "citizen"."id" AS "citizen.id" FROM "citizen" LEFT JOIN "company" AS "citizen_company_company" ON "citizen"."companyId" = "citizen_company_company"."id" WHERE "citizen_company_company"."name" = \'Serverpod\''); }); test( @@ -294,7 +294,7 @@ void main() { .build(); expect(query, - 'SELECT citizen."id" AS "citizen.id" FROM "citizen" LEFT JOIN "company" AS citizen_company_company ON citizen."companyId" = citizen_company_company."id" LEFT JOIN "citizen" AS citizen_company_company_ceo_citizen ON citizen_company_company."ceoId" = citizen_company_company_ceo_citizen."id" WHERE citizen_company_company_ceo_citizen."name" = \'Alex\''); + 'SELECT "citizen"."id" AS "citizen.id" FROM "citizen" LEFT JOIN "company" AS "citizen_company_company" ON "citizen"."companyId" = "citizen_company_company"."id" LEFT JOIN "citizen" AS "citizen_company_company_ceo_citizen" ON "citizen_company_company"."ceoId" = "citizen_company_company_ceo_citizen"."id" WHERE "citizen_company_company_ceo_citizen"."name" = \'Alex\''); }); test('when all properties configured is built then output is valid SQL.', @@ -329,7 +329,7 @@ void main() { .build(); expect(query, - 'SELECT citizen."id" AS "citizen.id", citizen."name" AS "citizen.name", citizen."age" AS "citizen.age" FROM "citizen" LEFT JOIN "company" AS citizen_company_company ON citizen."companyId" = citizen_company_company."id" WHERE citizen_company_company."name" = \'Serverpod\' ORDER BY citizen."id" DESC LIMIT 10 OFFSET 5'); + 'SELECT "citizen"."id" AS "citizen.id", "citizen"."name" AS "citizen.name", "citizen"."age" AS "citizen.age" FROM "citizen" LEFT JOIN "company" AS "citizen_company_company" ON "citizen"."companyId" = "citizen_company_company"."id" WHERE "citizen_company_company"."name" = \'Serverpod\' ORDER BY "citizen"."id" DESC LIMIT 10 OFFSET 5'); }); test( @@ -344,7 +344,7 @@ void main() { (e) => e.toString(), 'message', equals( - 'FormatException: Column references starting from other tables than "citizen" are not supported. The following expressions need to be removed or modified:\n"where" expression referencing column company."name".'), + 'FormatException: Column references starting from other tables than "citizen" are not supported. The following expressions need to be removed or modified:\n"where" expression referencing column "company"."name".'), ))); }); @@ -359,7 +359,7 @@ void main() { (e) => e.toString(), 'message', equals( - 'FormatException: Column references starting from other tables than "citizen" are not supported. The following expressions need to be removed or modified:\n"orderBy" expression referencing column company."name".'), + 'FormatException: Column references starting from other tables than "citizen" are not supported. The following expressions need to be removed or modified:\n"orderBy" expression referencing column "company"."name".'), ))); }); @@ -386,14 +386,14 @@ void main() { test('when default initialized then build outputs a valid SQL query.', () { var query = CountQueryBuilder(table: citizenTable).build(); - expect(query, 'SELECT COUNT(citizen."id") FROM "citizen"'); + expect(query, 'SELECT COUNT("citizen"."id") FROM "citizen"'); }); test('when query with alias is built then count result has defined alias.', () { var query = CountQueryBuilder(table: citizenTable).withCountAlias('c').build(); - expect(query, 'SELECT COUNT(citizen."id") AS c FROM "citizen"'); + expect(query, 'SELECT COUNT("citizen"."id") AS c FROM "citizen"'); }); test('when query with field is built then count is based on that field.', @@ -402,7 +402,7 @@ void main() { .withField(ColumnInt('age', citizenTable)) .build(); - expect(query, 'SELECT COUNT(citizen."age") FROM "citizen"'); + expect(query, 'SELECT COUNT("citizen"."age") FROM "citizen"'); }); test( @@ -413,14 +413,14 @@ void main() { .build(); expect(query, - 'SELECT COUNT(citizen."id") FROM "citizen" WHERE "test"=@test'); + 'SELECT COUNT("citizen"."id") FROM "citizen" WHERE "test"=@test'); }); test('when query with limit is built then output is a query with limit.', () { var query = CountQueryBuilder(table: citizenTable).withLimit(10).build(); - expect(query, 'SELECT COUNT(citizen."id") FROM "citizen" LIMIT 10'); + expect(query, 'SELECT COUNT("citizen"."id") FROM "citizen" LIMIT 10'); }); test( @@ -445,7 +445,7 @@ void main() { .build(); expect(query, - 'SELECT COUNT(citizen."id") FROM "citizen" LEFT JOIN "company" AS citizen_company_company ON citizen."companyId" = citizen_company_company."id" WHERE citizen_company_company."name" = \'Serverpod\''); + 'SELECT COUNT("citizen"."id") FROM "citizen" LEFT JOIN "company" AS "citizen_company_company" ON "citizen"."companyId" = "citizen_company_company"."id" WHERE "citizen_company_company"."name" = \'Serverpod\''); }); test( @@ -475,7 +475,7 @@ void main() { .build(); expect(query, - 'SELECT COUNT(citizen."id") FROM "citizen" LEFT JOIN "company" AS citizen_company_company ON citizen."companyId" = citizen_company_company."id" LEFT JOIN "citizen" AS citizen_company_company_ceo_citizen ON citizen_company_company."ceoId" = citizen_company_company_ceo_citizen."id" WHERE citizen_company_company_ceo_citizen."name" = \'Alex\''); + 'SELECT COUNT("citizen"."id") FROM "citizen" LEFT JOIN "company" AS "citizen_company_company" ON "citizen"."companyId" = "citizen_company_company"."id" LEFT JOIN "citizen" AS "citizen_company_company_ceo_citizen" ON "citizen_company_company"."ceoId" = "citizen_company_company_ceo_citizen"."id" WHERE "citizen_company_company_ceo_citizen"."name" = \'Alex\''); }); test( @@ -502,7 +502,7 @@ void main() { .build(); expect(query, - 'SELECT COUNT(citizen."age") AS c FROM "citizen" LEFT JOIN "company" AS citizen_company_company ON citizen."companyId" = citizen_company_company."id" WHERE citizen_company_company."name" = \'Serverpod\' LIMIT 10'); + 'SELECT COUNT("citizen"."age") AS c FROM "citizen" LEFT JOIN "company" AS "citizen_company_company" ON "citizen"."companyId" = "citizen_company_company"."id" WHERE "citizen_company_company"."name" = \'Serverpod\' LIMIT 10'); }); test( @@ -517,7 +517,7 @@ void main() { (e) => e.toString(), 'message', equals( - 'FormatException: Column references starting from other tables than "citizen" are not supported. The following expressions need to be removed or modified:\n"where" expression referencing column company."name".'), + 'FormatException: Column references starting from other tables than "citizen" are not supported. The following expressions need to be removed or modified:\n"where" expression referencing column "company"."name".'), ))); }); @@ -594,7 +594,7 @@ void main() { .build(); expect(query, - 'DELETE FROM "citizen" USING "company" AS citizen_company_company WHERE citizen_company_company."name" = \'Serverpod\' AND citizen."companyId" = citizen_company_company."id"'); + 'DELETE FROM "citizen" USING "company" AS "citizen_company_company" WHERE "citizen_company_company"."name" = \'Serverpod\' AND "citizen"."companyId" = "citizen_company_company"."id"'); }); test( @@ -621,7 +621,7 @@ void main() { .build(); expect(query, - 'DELETE FROM "citizen" USING "company" AS citizen_company_company, "citizen" AS citizen_company_company_ceo_citizen WHERE citizen_company_company_ceo_citizen."name" = \'Alex\' AND citizen."companyId" = citizen_company_company."id" AND citizen_company_company."ceoId" = citizen_company_company_ceo_citizen."id"'); + 'DELETE FROM "citizen" USING "company" AS "citizen_company_company", "citizen" AS "citizen_company_company_ceo_citizen" WHERE "citizen_company_company_ceo_citizen"."name" = \'Alex\' AND "citizen"."companyId" = "citizen_company_company"."id" AND "citizen_company_company"."ceoId" = "citizen_company_company_ceo_citizen"."id"'); }); test( @@ -644,7 +644,7 @@ void main() { .build(); expect(query, - 'DELETE FROM "citizen" USING "company" AS citizen_company_company WHERE citizen_company_company."name" = \'Serverpod\' AND citizen."companyId" = citizen_company_company."id" RETURNING *'); + 'DELETE FROM "citizen" USING "company" AS "citizen_company_company" WHERE "citizen_company_company"."name" = \'Serverpod\' AND "citizen"."companyId" = "citizen_company_company"."id" RETURNING *'); }); test( @@ -659,7 +659,7 @@ void main() { (e) => e.toString(), 'message', equals( - 'FormatException: Column references starting from other tables than "citizen" are not supported. The following expressions need to be removed or modified:\n"where" expression referencing column company."name".'), + 'FormatException: Column references starting from other tables than "citizen" are not supported. The following expressions need to be removed or modified:\n"where" expression referencing column "company"."name".'), ))); }); diff --git a/packages/serverpod/test/database/table_relation_test.dart b/packages/serverpod/test/database/table_relation_test.dart index f82f9e7ed3..d00a3c465d 100644 --- a/packages/serverpod/test/database/table_relation_test.dart +++ b/packages/serverpod/test/database/table_relation_test.dart @@ -58,12 +58,13 @@ void main() { test( 'when lastJoiningField is called then last joining field name is returned.', () { - expect(tableRelation.lastJoiningField, 'company."ceoId"'); + expect(tableRelation.lastJoiningField, '"company"."ceoId"'); }); test('when lastJoiningForeignField is called then last foreign field name.', () { - expect(tableRelation.lastJoiningForeignField, 'company_ceo_citizen."id"'); + expect( + tableRelation.lastJoiningForeignField, '"company_ceo_citizen"."id"'); }); group('when using copyAndAppend to create new table relation ', () { @@ -145,13 +146,13 @@ void main() { 'when lastJoiningField is called then last joining field name is returned.', () { expect(tableRelation.lastJoiningField, - 'company_ceo_citizen."favoriteRestaurantId"'); + '"company_ceo_citizen"."favoriteRestaurantId"'); }); test('when lastJoiningForeignField is called then last foreign field name.', () { expect(tableRelation.lastJoiningForeignField, - 'company_ceo_citizen_favoriteRestaurant_restaurant."id"'); + '"company_ceo_citizen_favoriteRestaurant_restaurant"."id"'); }); }); } diff --git a/tests/serverpod_test_server/test/database_operations/entity_relations/sql_query_test.dart b/tests/serverpod_test_server/test/database_operations/entity_relations/sql_query_test.dart index 6ab3235a3b..2806a049df 100644 --- a/tests/serverpod_test_server/test/database_operations/entity_relations/sql_query_test.dart +++ b/tests/serverpod_test_server/test/database_operations/entity_relations/sql_query_test.dart @@ -18,15 +18,15 @@ void main() { query, ''' SELECT - citizen."id" AS "citizen.id", - citizen."name" AS "citizen.name", - citizen."companyId" AS "citizen.companyId", - citizen."oldCompanyId" AS "citizen.oldCompanyId", - citizen_company_company."id" AS "citizen_company_company.id", - citizen_company_company."name" AS "citizen_company_company.name", - citizen_company_company."townId" AS "citizen_company_company.townId" + "citizen"."id" AS "citizen.id", + "citizen"."name" AS "citizen.name", + "citizen"."companyId" AS "citizen.companyId", + "citizen"."oldCompanyId" AS "citizen.oldCompanyId", + "citizen_company_company"."id" AS "citizen_company_company.id", + "citizen_company_company"."name" AS "citizen_company_company.name", + "citizen_company_company"."townId" AS "citizen_company_company.townId" FROM "citizen" -LEFT JOIN "company" AS citizen_company_company ON citizen."companyId" = citizen_company_company."id" +LEFT JOIN "company" AS "citizen_company_company" ON "citizen"."companyId" = "citizen_company_company"."id" ''' .replaceAll("\n", "")); }); diff --git a/tests/serverpod_test_server/test/database_operations/entity_relations/table_test.dart b/tests/serverpod_test_server/test/database_operations/entity_relations/table_test.dart index c1178a1d25..de5ba1b11b 100644 --- a/tests/serverpod_test_server/test/database_operations/entity_relations/table_test.dart +++ b/tests/serverpod_test_server/test/database_operations/entity_relations/table_test.dart @@ -11,7 +11,7 @@ void main() { test('then query prefix is built based on relations.', () { expect(expression.toString(), - '(citizen_oldCompany_company_town_town_mayor_citizen."name" = \'Alex\' AND citizen_company_company."name" = \'Serverpod\')'); + '("citizen_oldCompany_company_town_town_mayor_citizen"."name" = \'Alex\' AND "citizen_company_company"."name" = \'Serverpod\')'); }); test('then each in expression column is retrievable.', () { @@ -34,7 +34,7 @@ void main() { test('then query prefix is built based on relations.', () { expect(nestedRelationAccess.toString(), - 'citizen_oldCompany_company_town_town_mayor_citizen."name"'); + '"citizen_oldCompany_company_town_town_mayor_citizen"."name"'); }); test('then table relations exists.', () { @@ -58,8 +58,8 @@ void main() { actualTableRelation: firstTableRelation, expectedLastForeignTableName: 'company', expectedRelationQueryAlias: 'citizen_oldCompany_company', - expectedLastJoiningField: 'citizen."oldCompanyId"', - expectedLastJoiningForeignField: 'citizen_oldCompany_company."id"', + expectedLastJoiningField: '"citizen"."oldCompanyId"', + expectedLastJoiningForeignField: '"citizen_oldCompany_company"."id"', ); }, skip: nestedRelationAccess.table.tableRelation == null); @@ -73,9 +73,9 @@ void main() { actualTableRelation: secondTableRelation, expectedLastForeignTableName: 'town', expectedRelationQueryAlias: 'citizen_oldCompany_company_town_town', - expectedLastJoiningField: 'citizen_oldCompany_company."townId"', + expectedLastJoiningField: '"citizen_oldCompany_company"."townId"', expectedLastJoiningForeignField: - 'citizen_oldCompany_company_town_town."id"', + '"citizen_oldCompany_company_town_town"."id"', ); }, skip: nestedRelationAccess.table.tableRelation == null); @@ -90,9 +90,9 @@ void main() { expectedRelationQueryAlias: 'citizen_oldCompany_company_town_town_mayor_citizen', expectedLastJoiningField: - 'citizen_oldCompany_company_town_town."mayorId"', + '"citizen_oldCompany_company_town_town"."mayorId"', expectedLastJoiningForeignField: - 'citizen_oldCompany_company_town_town_mayor_citizen."id"', + '"citizen_oldCompany_company_town_town_mayor_citizen"."id"', ); }, skip: nestedRelationAccess.table.tableRelation == null); });