@@ -485,6 +485,30 @@ describe('SQL Generator', () => {
485485 const sql = generateSql ( opts ) ;
486486 expect ( sql ) . toEqual ( expectedSqlParts . join ( ' ' ) ) ;
487487 } ) ;
488+
489+ it ( 'generates table query with column names containing colons' , ( ) => {
490+ const opts : QueryBuilderOptions = {
491+ database : 'default' ,
492+ table : 'verifications' ,
493+ queryType : QueryType . Table ,
494+ columns : [
495+ { name : 'verification:id' , type : 'String' } ,
496+ { name : 'my:name' , type : 'String' } ,
497+ { name : 'regular_column' , type : 'String' } ,
498+ ] ,
499+ limit : 1000 ,
500+ filters : [ ] ,
501+ orderBy : [ ] ,
502+ } ;
503+
504+ const expectedSqlParts = [
505+ 'SELECT "verification:id", "my:name", regular_column' ,
506+ 'FROM "default"."verifications" LIMIT 1000' ,
507+ ] ;
508+
509+ const sql = generateSql ( opts ) ;
510+ expect ( sql ) . toEqual ( expectedSqlParts . join ( ' ' ) ) ;
511+ } ) ;
488512} ) ;
489513
490514describe ( 'isAggregateQuery' , ( ) => {
@@ -551,6 +575,10 @@ describe('getColumnIdentifier', () => {
551575 { input : { name : 'test with alias' , alias : 'a' } , expected : `"test with alias" as "a"` } ,
552576 { input : { name : 'test_with_alias' , alias : 'b' } , expected : `test_with_alias as "b"` } ,
553577 { input : { name : '"test" as a' , alias : '' } , expected : `"test" as a` } ,
578+ { input : { name : 'verification:id' } , expected : `"verification:id"` } ,
579+ { input : { name : 'my:name' } , expected : `"my:name"` } ,
580+ { input : { name : 'namespace:field:value' } , expected : `"namespace:field:value"` } ,
581+ { input : { name : 'verification:id' , alias : 'vid' } , expected : `"verification:id" as "vid"` } ,
554582 ] ;
555583
556584 it . each ( cases ) ( 'returns correct identifier (case %#)' , ( c ) => {
0 commit comments