Skip to content

Commit

Permalink
Fix integration tests by removing RQB support for now
Browse files Browse the repository at this point in the history
  • Loading branch information
AndriiSherman committed Nov 28, 2024
1 parent f704bb8 commit b71f896
Show file tree
Hide file tree
Showing 6 changed files with 6,654 additions and 6,659 deletions.
51 changes: 20 additions & 31 deletions drizzle-orm/src/singlestore-core/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { entityKind } from '~/entity.ts';
import type { TypedQueryBuilder } from '~/query-builders/query-builder.ts';
import type { ExtractTablesWithRelations, RelationalSchemaConfig, TablesRelationalConfig } from '~/relations.ts';
import { SelectionProxyHandler } from '~/selection-proxy.ts';
import type { SingleStoreDriverDatabase } from '~/singlestore/driver.ts';
import { type ColumnsSelection, type SQL, sql, type SQLWrapper } from '~/sql/sql.ts';
import { WithSubquery } from '~/subquery.ts';
import type { DrizzleTypeError } from '~/utils.ts';
import type { SingleStoreDialect } from './dialect.ts';
import { SingleStoreCountBuilder } from './query-builders/count.ts';
import {
Expand All @@ -15,7 +15,6 @@ import {
SingleStoreSelectBuilder,
SingleStoreUpdateBuilder,
} from './query-builders/index.ts';
import { RelationalQueryBuilder } from './query-builders/query.ts';
import type { SelectedFields } from './query-builders/select.types.ts';
import type {
PreparedQueryHKTBase,
Expand All @@ -42,11 +41,9 @@ export class SingleStoreDatabase<
readonly tableNamesMap: Record<string, string>;
};

query: TFullSchema extends Record<string, never>
? DrizzleTypeError<'Seems like the schema generic is missing - did you forget to add it to your DB type?'>
: {
[K in keyof TSchema]: RelationalQueryBuilder<TPreparedQueryHKT, TSchema, TSchema[K]>;
};
// We are waiting for SingleStore support for `json_array` function
/**@inrernal */
query: unknown;

constructor(
/** @internal */
Expand All @@ -67,20 +64,21 @@ export class SingleStoreDatabase<
tableNamesMap: {},
};
this.query = {} as typeof this['query'];
if (this._.schema) {
for (const [tableName, columns] of Object.entries(this._.schema)) {
(this.query as SingleStoreDatabase<TQueryResult, TPreparedQueryHKT, Record<string, any>>['query'])[tableName] =
new RelationalQueryBuilder(
schema!.fullSchema,
this._.schema,
this._.tableNamesMap,
schema!.fullSchema[tableName] as SingleStoreTable,
columns,
dialect,
session,
);
}
}
// this.queryNotSupported = true;
// if (this._.schema) {
// for (const [tableName, columns] of Object.entries(this._.schema)) {
// (this.query as SingleStoreDatabase<TQueryResult, TPreparedQueryHKT, Record<string, any>>['query'])[tableName] =
// new RelationalQueryBuilder(
// schema!.fullSchema,
// this._.schema,
// this._.tableNamesMap,
// schema!.fullSchema[tableName] as SingleStoreTable,
// columns,
// dialect,
// session,
// );
// }
// }
}

/**
Expand Down Expand Up @@ -484,16 +482,7 @@ export class SingleStoreDatabase<
export type SingleStoreWithReplicas<Q> = Q & { $primary: Q };

export const withReplicas = <
HKT extends SingleStoreQueryResultHKT,
TPreparedQueryHKT extends PreparedQueryHKTBase,
TFullSchema extends Record<string, unknown>,
TSchema extends TablesRelationalConfig,
Q extends SingleStoreDatabase<
HKT,
TPreparedQueryHKT,
TFullSchema,
TSchema extends Record<string, unknown> ? ExtractTablesWithRelations<TFullSchema> : TSchema
>,
Q extends SingleStoreDriverDatabase,
>(
primary: Q,
replicas: [Q, ...Q[]],
Expand Down
2 changes: 1 addition & 1 deletion drizzle-orm/src/singlestore-core/dialect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ export class SingleStoreDialect {
where = and(joinOn, where);

if (nestedQueryRelation) {
let field = sql`JSON_BUILD_OBJECT(${
let field = sql`JSON_TO_ARRAY(${
sql.join(
selection.map(({ field, tsKey, isJson }) =>
isJson
Expand Down
Loading

0 comments on commit b71f896

Please sign in to comment.