You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When writing any (not SELECT) queries with RETURNING statement in the end, the generated type does not respect column overrides.
To Reproduce
Simple table schema
createtabledummy (
id uuid primary key default gen_random_uuid(),
name textnot null,
created_at timestamp with time zoneNOT NULL default now(),
metadata jsonb NOT NULL default '{}'
);
safeql.config.ts
exportdefaultdefineConfig({connections: {
databaseUrl,targets: [{// The name of the sql tag that should be checked:tag: 'sql',// Postgres.js type should be an array, so we add an extra "[]" after the generated type:transform: '{type}[]',},],overrides: {columns: {'dummy.metadata': 'MetadataType',},types: {},},},});
Repository class
exporttypeMetadataType=Record<string,string>;exportclassDummyRepositoryRecord{id!: string;name!: string;created_at!: Date;metadata!: MetadataType;}exporttypeDummyType={id: string;name: string;created_at: Date;metadata: MetadataType;};
@Injectable()exportclassDummyRepository{constructor(@Inject(SQL_INJECT_TOKEN)privatesql: Sql){}asyncget(): Promise<void>{awaitthis.sql<DummyRepositoryRecord[]>` SELECT * FROM dummy `;}asyncgetWithType(): Promise<void>{awaitthis.sql<DummyType[]>` SELECT * FROM dummy `;}asynccreate(name: string): Promise<void>{awaitthis.sql<DummyType[]>` INSERT INTO dummy (name) VALUES (${name}) RETURNING * `;}asyncupdate(id: string,name: string): Promise<void>{awaitthis.sql<DummyType[]>` UPDATE dummy SET name = ${name} where id = ${id}::uuid RETURNING * `;}asyncdelete(id: string): Promise<void>{awaitthis.sql<DummyType[]>` DELETE FROM dummy WHERE id = ${id}::uuid RETURNING *`;}}
Expected behavior
I expect the DummyType generic not to be overriden by linting.
Screenshots
getWithType is the only method, which seems not to have any typescript related issues.
The state after linting has been executed:
Interesting fact. Classes types do not work as well, I mean, strictly speaking, that's probably not the intended usage of the library. Would be nice to hear a statement from the maintainers on it.
Desktop (please complete the following information):
OS: [macOS 15.2]
PostgreSQL version [16]
Version [3.6.6]
The text was updated successfully, but these errors were encountered:
Describe the bug
When writing any (not SELECT) queries with RETURNING statement in the end, the generated type does not respect column overrides.
To Reproduce
Simple table schema
safeql.config.ts
Repository class
Expected behavior
I expect the DummyType generic not to be overriden by linting.
Screenshots
getWithType
is the only method, which seems not to have any typescript related issues.The state after linting has been executed:

Interesting fact. Classes types do not work as well, I mean, strictly speaking, that's probably not the intended usage of the library. Would be nice to hear a statement from the maintainers on it.

Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: