@@ -554,4 +554,105 @@ describe('ScaffoldingSchema', () => {
554554 }
555555 ] ) ;
556556 } ) ;
557+
558+ describe ( 'columnType mapping for numeric types' , ( ) => {
559+ it ( 'should map FLOAT types to number' , ( ) => {
560+ const floatSchemas = {
561+ public : {
562+ test : [
563+ { name : 'float_col' , type : 'FLOAT' , attributes : [ ] } ,
564+ { name : 'float4_col' , type : 'FLOAT4' , attributes : [ ] } ,
565+ { name : 'float8_col' , type : 'FLOAT8' , attributes : [ ] } ,
566+ { name : 'float32_col' , type : 'FLOAT32' , attributes : [ ] } ,
567+ { name : 'float64_col' , type : 'FLOAT64' , attributes : [ ] } ,
568+ ]
569+ }
570+ } ;
571+ const schema = new ScaffoldingSchema ( floatSchemas ) ;
572+ floatSchemas . public . test . forEach ( col => {
573+ expect ( ( schema as any ) . columnType ( col ) ) . toBe ( 'number' ) ;
574+ } ) ;
575+ } ) ;
576+
577+ it ( 'should map REAL type to number' , ( ) => {
578+ const realSchemas = {
579+ public : {
580+ test : [ { name : 'real_col' , type : 'REAL' , attributes : [ ] } ]
581+ }
582+ } ;
583+ const schema = new ScaffoldingSchema ( realSchemas ) ;
584+ expect ( ( schema as any ) . columnType ( realSchemas . public . test [ 0 ] ) ) . toBe ( 'number' ) ;
585+ } ) ;
586+
587+ it ( 'should map SERIAL types to number' , ( ) => {
588+ const serialSchemas = {
589+ public : {
590+ test : [
591+ { name : 'serial_col' , type : 'SERIAL' , attributes : [ ] } ,
592+ { name : 'bigserial_col' , type : 'BIGSERIAL' , attributes : [ ] } ,
593+ { name : 'smallserial_col' , type : 'SMALLSERIAL' , attributes : [ ] } ,
594+ ]
595+ }
596+ } ;
597+ const schema = new ScaffoldingSchema ( serialSchemas ) ;
598+ serialSchemas . public . test . forEach ( col => {
599+ expect ( ( schema as any ) . columnType ( col ) ) . toBe ( 'number' ) ;
600+ } ) ;
601+ } ) ;
602+
603+ it ( 'should map MONEY types to number' , ( ) => {
604+ const moneySchemas = {
605+ public : {
606+ test : [
607+ { name : 'money_col' , type : 'MONEY' , attributes : [ ] } ,
608+ { name : 'smallmoney_col' , type : 'SMALLMONEY' , attributes : [ ] } ,
609+ ]
610+ }
611+ } ;
612+ const schema = new ScaffoldingSchema ( moneySchemas ) ;
613+ moneySchemas . public . test . forEach ( col => {
614+ expect ( ( schema as any ) . columnType ( col ) ) . toBe ( 'number' ) ;
615+ } ) ;
616+ } ) ;
617+
618+ it ( 'should map various integer types to number (covered by int keyword)' , ( ) => {
619+ const intSchemas = {
620+ public : {
621+ test : [
622+ // Standard integer types
623+ { name : 'tinyint_col' , type : 'TINYINT' , attributes : [ ] } ,
624+ { name : 'mediumint_col' , type : 'MEDIUMINT' , attributes : [ ] } ,
625+ { name : 'hugeint_col' , type : 'HUGEINT' , attributes : [ ] } ,
626+ // Unsigned integer types
627+ { name : 'uint8_col' , type : 'UINT8' , attributes : [ ] } ,
628+ { name : 'uint32_col' , type : 'UINT32' , attributes : [ ] } ,
629+ { name : 'uinteger_col' , type : 'UINTEGER' , attributes : [ ] } ,
630+ { name : 'ubigint_col' , type : 'UBIGINT' , attributes : [ ] } ,
631+ // Other variants
632+ { name : 'byteint_col' , type : 'BYTEINT' , attributes : [ ] } ,
633+ ]
634+ }
635+ } ;
636+ const schema = new ScaffoldingSchema ( intSchemas ) ;
637+ intSchemas . public . test . forEach ( col => {
638+ expect ( ( schema as any ) . columnType ( col ) ) . toBe ( 'number' ) ;
639+ } ) ;
640+ } ) ;
641+
642+ it ( 'should be case insensitive for type matching' , ( ) => {
643+ const caseSchemas = {
644+ public : {
645+ test : [
646+ { name : 'float_lower' , type : 'float' , attributes : [ ] } ,
647+ { name : 'float_upper' , type : 'FLOAT' , attributes : [ ] } ,
648+ { name : 'float_mixed' , type : 'Float' , attributes : [ ] } ,
649+ ]
650+ }
651+ } ;
652+ const schema = new ScaffoldingSchema ( caseSchemas ) ;
653+ caseSchemas . public . test . forEach ( col => {
654+ expect ( ( schema as any ) . columnType ( col ) ) . toBe ( 'number' ) ;
655+ } ) ;
656+ } ) ;
657+ } ) ;
557658} ) ;
0 commit comments