Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion packages/drivers/sql/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
import { Driver, IntrospectedSchema, IntrospectedTable, IntrospectedColumn, IntrospectedForeignKey } from '@objectql/types';
import knex, { Knex } from 'knex';

/**
* SQL Driver for ObjectQL
* Implements Driver interface from @objectql/types
*/
export class SqlDriver implements Driver {
private knex: Knex;
private config: any;
Expand Down Expand Up @@ -277,7 +281,7 @@ export class SqlDriver implements Driver {
}
}

// Bulk
// Bulk Operations
async createMany(objectName: string, data: any[], options?: any): Promise<any> {
const builder = this.getBuilder(objectName, options);
return await builder.insert(data).returning('*');
Expand Down Expand Up @@ -506,6 +510,8 @@ export class SqlDriver implements Driver {
return data;
}

/**

/**
Comment on lines +514 to 515
Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incomplete or malformed JSDoc comment. Line 513 contains an empty JSDoc opener that should be removed, as line 515 starts the actual documentation for the introspectSchema method.

Suggested change
/**

Copilot uses AI. Check for mistakes.
* Introspect the database schema to discover existing tables, columns, and relationships.
*/
Expand Down
18 changes: 10 additions & 8 deletions packages/foundation/core/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import {
HookContext,
ActionHandler,
ActionContext,
LoaderPlugin
LoaderPlugin,
Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused import LoaderPlugin.

Suggested change
LoaderPlugin,

Copilot uses AI. Check for mistakes.
Driver
} from '@objectql/types';
import { ObjectRepository } from './repository';

Expand All @@ -28,13 +29,12 @@ import { registerHookHelper, triggerHookHelper, HookEntry } from './hook';
import { registerObjectHelper, getConfigsHelper } from './object';
import { convertIntrospectedSchemaToObjects } from './util';

// Import ObjectStack engine and standard driver interface
// Import ObjectStack engine (without using its driver types)
import { ObjectQL as ObjectStackEngine } from '@objectstack/objectql';
import { DriverInterface } from '@objectstack/spec';

export class ObjectQL implements IObjectQL {
public metadata: MetadataRegistry;
private datasources: Record<string, DriverInterface> = {};
private datasources: Record<string, Driver> = {};
private remotes: string[] = [];
private hooks: Record<string, HookEntry[]> = {};
private actions: Record<string, ActionEntry> = {};
Expand All @@ -55,8 +55,9 @@ export class ObjectQL implements IObjectQL {
this.stackEngine = new ObjectStackEngine({});

// Register drivers with ObjectStack engine (no wrapping needed)
// Cast to any since our Driver interface is compatible with spec's DriverInterface
for (const [name, driver] of Object.entries(this.datasources)) {
this.stackEngine.registerDriver(driver, name === 'default');
this.stackEngine.registerDriver(driver as any, name === 'default');
Comment on lines +58 to +60
Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using type assertion 'as any' bypasses TypeScript's type checking and defeats the purpose of having strong type safety. While this is documented as a workaround for structural compatibility with spec's DriverInterface, it eliminates compile-time verification that our Driver interface is actually compatible with DriverInterface. Consider either: (1) creating a proper type adapter/wrapper function that ensures compatibility at compile time, or (2) contributing to @objectstack/spec to export a non-Zod-inferred Driver type that can be structurally matched.

Copilot uses AI. Check for mistakes.
}

if (config.connection) {
Expand Down Expand Up @@ -89,12 +90,13 @@ export class ObjectQL implements IObjectQL {
/**
* Register a new driver with ObjectStack engine
*/
registerDriver(name: string, driver: DriverInterface, isDefault: boolean = false) {
registerDriver(name: string, driver: Driver, isDefault: boolean = false) {
if (this.datasources[name]) {
console.warn(`[ObjectQL] Driver '${name}' already exists. Overwriting...`);
}
this.datasources[name] = driver;
this.stackEngine.registerDriver(driver, isDefault);
// Cast to any since our Driver interface is compatible with spec's DriverInterface
this.stackEngine.registerDriver(driver as any, isDefault);
Comment on lines +98 to +99
Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using type assertion 'as any' bypasses TypeScript's type checking and defeats the purpose of having strong type safety. While this is documented as a workaround for structural compatibility with spec's DriverInterface, it eliminates compile-time verification that our Driver interface is actually compatible with DriverInterface. Consider either: (1) creating a proper type adapter/wrapper function that ensures compatibility at compile time, or (2) contributing to @objectstack/spec to export a non-Zod-inferred Driver type that can be structurally matched.

Copilot uses AI. Check for mistakes.
}

removePackage(name: string) {
Expand Down Expand Up @@ -189,7 +191,7 @@ export class ObjectQL implements IObjectQL {
return getConfigsHelper(this.metadata);
}

datasource(name: string): DriverInterface {
datasource(name: string): Driver {
const driver = this.datasources[name];
if (!driver) {
throw new Error(`Datasource '${name}' not found`);
Expand Down
6 changes: 3 additions & 3 deletions packages/foundation/types/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
import { MetadataRegistry } from "./registry";
import { ObjectConfig } from "./object";
import { ObjectQLPlugin } from "./plugin";
// Import DriverInterface from @objectstack/spec
import type { DriverInterface } from "@objectstack/spec";
// Import Driver from local types package
import type { Driver } from "./driver";

export interface ObjectQLConfig {
registry?: MetadataRegistry;
datasources?: Record<string, DriverInterface>;
datasources?: Record<string, Driver>;
/**
* Optional connection string for auto-configuration.
* e.g. "sqlite://dev.db", "postgres://localhost/db", "mongodb://localhost/db"
Expand Down
25 changes: 0 additions & 25 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading