@@ -24,6 +24,7 @@ import { Pool as PgPool } from 'pg';
2424import { CliError } from '../cli-error' ;
2525import { getVersion } from '../utils/version-utils' ;
2626import { getOutputPath , getSchemaFile , loadSchemaDocument } from './action-utils' ;
27+ import type { SchemaDef } from '@zenstackhq/orm/schema' ;
2728
2829type Options = {
2930 output ?: string ;
@@ -72,9 +73,25 @@ export async function run(options: Options) {
7273
7374 const schemaModule = ( await jiti . import ( path . join ( outputPath , 'schema' ) ) ) as any ;
7475
75- const db = new ZenStackClient ( schemaModule . schema , {
76+ // Build omit configuration for computed fields
77+ const schema = schemaModule . schema as SchemaDef ;
78+ const omit : Record < string , Record < string , boolean > > = { } ;
79+ for ( const [ modelName , modelDef ] of Object . entries ( schema . models ) ) {
80+ const computedFields : Record < string , boolean > = { } ;
81+ for ( const [ fieldName , fieldDef ] of Object . entries ( modelDef . fields ) ) {
82+ if ( fieldDef . computed === true ) {
83+ computedFields [ fieldName ] = true ;
84+ }
85+ }
86+ if ( Object . keys ( computedFields ) . length > 0 ) {
87+ omit [ modelName ] = computedFields ;
88+ }
89+ }
90+
91+ const db = new ZenStackClient ( schema , {
7692 dialect : dialect ,
7793 log : log && log . length > 0 ? log : undefined ,
94+ omit : Object . keys ( omit ) . length > 0 ? omit : undefined ,
7895 } ) ;
7996
8097 // check whether the database is reachable
0 commit comments