@@ -101,7 +101,7 @@ export const apply = async ({
101
101
}
102
102
return { name, type : tsType }
103
103
} )
104
- . sort ( ( a , b ) => a . name . localeCompare ( b . name ) )
104
+ . toSorted ( ( a , b ) => a . name . localeCompare ( b . name ) )
105
105
106
106
return `{
107
107
${ argsNameAndType . map ( ( { name, type } ) => `${ JSON . stringify ( name ) } : ${ type } ` ) }
@@ -113,6 +113,7 @@ export const apply = async ({
113
113
if ( relation ) {
114
114
return `{
115
115
${ columnsByTableId [ relation . id ]
116
+ . toSorted ( ( a , b ) => a . name . localeCompare ( b . name ) )
116
117
. map (
117
118
( column ) =>
118
119
`${ JSON . stringify ( column . name ) } : ${ pgTypeToTsType ( schema , column . format , {
@@ -571,7 +572,7 @@ export type Database = {
571
572
}
572
573
return { name, type : tsType , has_default }
573
574
} )
574
- argsType = `{ ${ argsNameAndType . map ( ( { name, type, has_default } ) => `${ JSON . stringify ( name ) } ${ has_default ? '?' : '' } : ${ type } ` ) } }`
575
+ argsType = `{ ${ argsNameAndType . toSorted ( ( a , b ) => a . name . localeCompare ( b . name ) ) . map ( ( { name, type, has_default } ) => `${ JSON . stringify ( name ) } ${ has_default ? '?' : '' } : ${ type } ` ) } }`
575
576
}
576
577
returnType = `{ error: true } & ${ JSON . stringify ( conflictError ) } `
577
578
} else if ( hasTableRowError ( fn ) ) {
@@ -590,7 +591,7 @@ export type Database = {
590
591
}
591
592
return { name, type : tsType , has_default }
592
593
} )
593
- argsType = `{ ${ argsNameAndType . map ( ( { name, type, has_default } ) => `${ JSON . stringify ( name ) } ${ has_default ? '?' : '' } : ${ type } ` ) } }`
594
+ argsType = `{ ${ argsNameAndType . toSorted ( ( a , b ) => a . name . localeCompare ( b . name ) ) . map ( ( { name, type, has_default } ) => `${ JSON . stringify ( name ) } ${ has_default ? '?' : '' } : ${ type } ` ) } }`
594
595
}
595
596
returnType = `{ error: true } & ${ JSON . stringify ( `the function ${ schema . name } .${ fn . name } with parameter or with a single unnamed json/jsonb parameter, but no matches were found in the schema cache` ) } `
596
597
} else if ( inArgs . length > 0 ) {
@@ -607,7 +608,7 @@ export type Database = {
607
608
}
608
609
return { name, type : tsType , has_default }
609
610
} )
610
- argsType = `{ ${ argsNameAndType . map ( ( { name, type, has_default } ) => `${ JSON . stringify ( name ) } ${ has_default ? '?' : '' } : ${ type } ` ) } }`
611
+ argsType = `{ ${ argsNameAndType . toSorted ( ( a , b ) => a . name . localeCompare ( b . name ) ) . map ( ( { name, type, has_default } ) => `${ JSON . stringify ( name ) } ${ has_default ? '?' : '' } : ${ type } ` ) } }`
611
612
}
612
613
613
614
return `{ Args: ${ argsType } ; Returns: ${ getFunctionTsReturnType ( fn , returnType ) } }`
0 commit comments