@@ -464,30 +464,58 @@ export type ResolveForwardRelationship<
464464 CurrentTableOrView ,
465465 Field [ 'name' ]
466466 > extends infer FoundEmbededFunctionJoinTableRelation
467- ? FoundEmbededFunctionJoinTableRelation extends GenericSetofOption
468- ? {
469- referencedTable : TablesAndViews < Schema > [ FoundEmbededFunctionJoinTableRelation [ 'to' ] ]
470- relation : {
471- foreignKeyName : `${Field [ 'name' ] } _${CurrentTableOrView } _${FoundEmbededFunctionJoinTableRelation [ 'to' ] } _forward`
472- columns : [ ]
473- isOneToOne : FoundEmbededFunctionJoinTableRelation [ 'isOneToOne' ] extends true
474- ? true
475- : false
476- referencedColumns : [ ]
477- referencedRelation : FoundEmbededFunctionJoinTableRelation [ 'to' ]
478- } & {
479- match : 'func'
480- isNotNullable : FoundEmbededFunctionJoinTableRelation [ 'isNotNullable' ] extends true
481- ? true
482- : FoundEmbededFunctionJoinTableRelation [ 'isSetofReturn' ] extends true
483- ? false
484- : true
485- isSetofReturn : FoundEmbededFunctionJoinTableRelation [ 'isSetofReturn' ]
486- }
487- direction : 'forward'
488- from : CurrentTableOrView
489- type : 'found-by-embeded-function'
490- }
467+ ? FoundEmbededFunctionJoinTableRelation extends GenericFunction
468+ ? FoundEmbededFunctionJoinTableRelation [ 'SetofOptions' ] extends GenericSetofOption
469+ ? FoundEmbededFunctionJoinTableRelation [ 'SetofOptions' ] [ 'to' ] extends ''
470+ ? // Scalar computed column: function returns a primitive (not a table row).
471+ // `to` is '' because there is no target table — the value is returned directly.
472+ {
473+ referencedTable : { Row : Record < string , never > ; Relationships : [ ] }
474+ relation : {
475+ foreignKeyName : `${Field [ 'name' ] } _${CurrentTableOrView } _scalar_forward`
476+ columns : [ ]
477+ isOneToOne : false
478+ referencedColumns : [ ]
479+ referencedRelation : ''
480+ } & {
481+ match : 'func'
482+ isNotNullable : FoundEmbededFunctionJoinTableRelation [ 'SetofOptions' ] [ 'isNotNullable' ] extends true
483+ ? true
484+ : FoundEmbededFunctionJoinTableRelation [ 'SetofOptions' ] [ 'isSetofReturn' ] extends true
485+ ? false
486+ : true
487+ isSetofReturn : FoundEmbededFunctionJoinTableRelation [ 'SetofOptions' ] [ 'isSetofReturn' ]
488+ }
489+ scalarType : FoundEmbededFunctionJoinTableRelation [ 'Returns' ]
490+ direction : 'forward'
491+ from : CurrentTableOrView
492+ type : 'found-by-embeded-scalar-function'
493+ }
494+ : // Table-valued function: `to` names the target table/view.
495+ {
496+ referencedTable : TablesAndViews < Schema > [ FoundEmbededFunctionJoinTableRelation [ 'SetofOptions' ] [ 'to' ] ]
497+ relation : {
498+ foreignKeyName : `${Field [ 'name' ] } _${CurrentTableOrView } _${FoundEmbededFunctionJoinTableRelation [ 'SetofOptions' ] [ 'to' ] } _forward`
499+ columns : [ ]
500+ isOneToOne : FoundEmbededFunctionJoinTableRelation [ 'SetofOptions' ] [ 'isOneToOne' ] extends true
501+ ? true
502+ : false
503+ referencedColumns : [ ]
504+ referencedRelation : FoundEmbededFunctionJoinTableRelation [ 'SetofOptions' ] [ 'to' ]
505+ } & {
506+ match : 'func'
507+ isNotNullable : FoundEmbededFunctionJoinTableRelation [ 'SetofOptions' ] [ 'isNotNullable' ] extends true
508+ ? true
509+ : FoundEmbededFunctionJoinTableRelation [ 'SetofOptions' ] [ 'isSetofReturn' ] extends true
510+ ? false
511+ : true
512+ isSetofReturn : FoundEmbededFunctionJoinTableRelation [ 'SetofOptions' ] [ 'isSetofReturn' ]
513+ }
514+ direction : 'forward'
515+ from : CurrentTableOrView
516+ type : 'found-by-embeded-function'
517+ }
518+ : SelectQueryError < `could not find the relation between ${CurrentTableOrView } and ${Field [ 'name' ] } `>
491519 : SelectQueryError < `could not find the relation between ${CurrentTableOrView } and ${Field [ 'name' ] } `>
492520 : SelectQueryError < `could not find the relation between ${CurrentTableOrView } and ${Field [ 'name' ] } `>
493521 : SelectQueryError < `could not find the relation between ${CurrentTableOrView } and ${Field [ 'name' ] } `>
@@ -542,7 +570,7 @@ type ResolveEmbededFunctionJoinTableRelationship<
542570 CurrentTableOrView
543571 > extends infer Fn
544572 ? Fn extends GenericFunction
545- ? Fn [ 'SetofOptions' ]
573+ ? Fn
546574 : false
547575 : false
548576
0 commit comments