File tree Expand file tree Collapse file tree 3 files changed +9
-7
lines changed
libs/json-api-nestjs/src/lib Expand file tree Collapse file tree 3 files changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -19,9 +19,11 @@ describe('Test utils', () => {
1919 const result = snakeToCamel ( 'test_test' ) ;
2020 const result1 = snakeToCamel ( 'test-test' ) ;
2121 const result2 = snakeToCamel ( 'testTest' ) ;
22+ const result3 = snakeToCamel ( 'event_incident_typeFK' ) ;
2223 expect ( result ) . toBe ( 'testTest' ) ;
2324 expect ( result1 ) . toBe ( 'testTest' ) ;
2425 expect ( result2 ) . toBe ( 'testTest' ) ;
26+ expect ( result3 ) . toBe ( 'eventIncidentTypeFK' ) ;
2527 } ) ;
2628
2729 it ( 'isString' , ( ) => {
Original file line number Diff line number Diff line change @@ -35,11 +35,9 @@ export function snakeToCamel(str: string): string {
3535 if ( ! str . match ( / [ \s _ - ] / g) ) {
3636 return str ;
3737 }
38- return str
39- . toLowerCase ( )
40- . replace ( / ( [ - _ ] [ a - z ] ) / g, ( group ) =>
41- group . toUpperCase ( ) . replace ( '-' , '' ) . replace ( '_' , '' )
42- ) ;
38+ return str . replace ( / ( [ - _ ] [ a - z ] ) / g, ( group ) =>
39+ group . toUpperCase ( ) . replace ( '-' , '' ) . replace ( '_' , '' )
40+ ) ;
4341}
4442
4543export function camelToKebab ( str : string ) : string {
Original file line number Diff line number Diff line change @@ -122,7 +122,7 @@ export class TransformMixinService<T> {
122122 this . commonColumnsForRelation . has ( tableName ) &&
123123 this . commonColumnsForRelation . get ( tableName ) . has ( fieldName )
124124 ) {
125- if ( ! currentItem [ field ] ) {
125+ if ( ! ( field in currentItem ) ) {
126126 continue ;
127127 }
128128 relationObject [ tableName ] = relationObject [ tableName ] || { } ;
@@ -141,7 +141,9 @@ export class TransformMixinService<T> {
141141 val
142142 ) ;
143143 if ( Array . isArray ( acum [ key ] ) ) {
144- acum [ key ] . push ( plainObject ) ;
144+ if ( plainObject [ this . relationPrimaryField . get ( key ) ] !== null ) {
145+ acum [ key ] . push ( plainObject ) ;
146+ }
145147 } else {
146148 acum [ key ] = plainObject ;
147149 }
You can’t perform that action at this time.
0 commit comments