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', () => {
19
19
const result = snakeToCamel ( 'test_test' ) ;
20
20
const result1 = snakeToCamel ( 'test-test' ) ;
21
21
const result2 = snakeToCamel ( 'testTest' ) ;
22
+ const result3 = snakeToCamel ( 'event_incident_typeFK' ) ;
22
23
expect ( result ) . toBe ( 'testTest' ) ;
23
24
expect ( result1 ) . toBe ( 'testTest' ) ;
24
25
expect ( result2 ) . toBe ( 'testTest' ) ;
26
+ expect ( result3 ) . toBe ( 'eventIncidentTypeFK' ) ;
25
27
} ) ;
26
28
27
29
it ( 'isString' , ( ) => {
Original file line number Diff line number Diff line change @@ -35,11 +35,9 @@ export function snakeToCamel(str: string): string {
35
35
if ( ! str . match ( / [ \s _ - ] / g) ) {
36
36
return str ;
37
37
}
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
+ ) ;
43
41
}
44
42
45
43
export function camelToKebab ( str : string ) : string {
Original file line number Diff line number Diff line change @@ -122,7 +122,7 @@ export class TransformMixinService<T> {
122
122
this . commonColumnsForRelation . has ( tableName ) &&
123
123
this . commonColumnsForRelation . get ( tableName ) . has ( fieldName )
124
124
) {
125
- if ( ! currentItem [ field ] ) {
125
+ if ( ! ( field in currentItem ) ) {
126
126
continue ;
127
127
}
128
128
relationObject [ tableName ] = relationObject [ tableName ] || { } ;
@@ -141,7 +141,9 @@ export class TransformMixinService<T> {
141
141
val
142
142
) ;
143
143
if ( Array . isArray ( acum [ key ] ) ) {
144
- acum [ key ] . push ( plainObject ) ;
144
+ if ( plainObject [ this . relationPrimaryField . get ( key ) ] !== null ) {
145
+ acum [ key ] . push ( plainObject ) ;
146
+ }
145
147
} else {
146
148
acum [ key ] = plainObject ;
147
149
}
You can’t perform that action at this time.
0 commit comments