Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
fhur committed Sep 30, 2024
1 parent af6f014 commit dc7c8a7
Show file tree
Hide file tree
Showing 37 changed files with 101 additions and 62 deletions.
6 changes: 3 additions & 3 deletions packages/backend/src/execution/execute.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { col, query } from '@synthql/queries';
import { query } from '@synthql/queries';
import { describe, expect, test } from 'vitest';
import { collectLast } from '..';
import { QueryProvider } from '../QueryProvider';
import { DB, schema } from '../tests/generated';
import { DB, ref, schema } from '../tests/generated';
import { PgCatalogInt4, PgCatalogText } from '../tests/generated/db';
import { execute } from './execute';
import { QueryProviderExecutor } from './executors/QueryProviderExecutor';
Expand Down Expand Up @@ -238,7 +238,7 @@ describe('execute', () => {
.include({
rating: from('film_rating')
.columns('rating')
.where({ film_id: col('film.film_id') })
.where({ film_id: ref('film.film_id') })
.one(),
})
.one();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { col } from '@synthql/queries';
import { describe, expect, it } from 'vitest';
import { PgExecutor } from '.';
import { from } from '../../../tests/generated';
import { col, from } from '../../../tests/generated';
import { pool } from '../../../tests/queryEngine';
import { QueryProviderExecutor } from '../QueryProviderExecutor';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { col } from '@synthql/queries';
import { describe, expect, test } from 'vitest';
import { PgExecutor } from '.';
import { col } from '../../../tests/generated';
import {
actor,
film,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { col } from '@synthql/queries';
import {} from '@synthql/queries';
import { describe, expect, test } from 'vitest';
import { col } from '../../../tests/generated';
import { convertWhereToQueryProviderInput } from './convertWhereToQueryProviderInput';

describe('convertWhereToQueryProviderInput', () => {
Expand Down Expand Up @@ -52,8 +53,8 @@ describe('convertWhereToQueryProviderInput', () => {
{ a: { match: 'a%' } },
{ a: { ilike: 'a%' } },
{ a: 1, b: { not: 2 } },
{ a: col<any>('b.a') },
{ a: col<any>('b.a'), b: 2 },
{ a: col('b.a' as never) },
{ a: col('b.a' as never), b: 2 },
];

describe('unsupported where clauses', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { col } from '@synthql/queries';
import { describe, expect, test } from 'vitest';
import { from } from '../../tests/generated';
import { col, from } from '../../tests/generated';
import { store } from '../../tests/queries.v2';
import { printPath } from '../../util/path/printPath';
import { PlanningQuery } from '../types';
Expand Down
4 changes: 2 additions & 2 deletions packages/backend/src/query/collectColumnReferences.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AnyQuery, QueryResult, col } from '@synthql/queries';
import { AnyQuery, QueryResult } from '@synthql/queries';
import { describe, expect, test } from 'vitest';
import { from } from '../tests/generated';
import { col, from } from '../tests/generated';
import { city } from '../tests/queries.v2';
import { collectColumnReferences } from './collectColumnReferences';

Expand Down
4 changes: 2 additions & 2 deletions packages/backend/src/query/iterateQuery.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AnyQuery, col } from '@synthql/queries';
import { AnyQuery } from '@synthql/queries';
import { describe, expect, test } from 'vitest';
import { Path } from '../execution/types';
import { from } from '../tests/generated';
import { col, from } from '../tests/generated';
import { iterateQuery } from './iterateQuery';

describe('iterateQuery', () => {
Expand Down
3 changes: 2 additions & 1 deletion packages/backend/src/query/iterateResultRow.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { QueryResult, col } from '@synthql/queries';
import { QueryResult } from '@synthql/queries';
import { describe, expect, test } from 'vitest';
import { col } from '../tests/generated';
import { city } from '../tests/queries.v2';
import { iterateResultRows } from './iterateResultRow';

Expand Down
5 changes: 2 additions & 3 deletions packages/backend/src/query/resolveReferences.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { describe, expect, test } from 'vitest';
import { col } from '@synthql/queries';
import { createRefContext } from '../refs/RefContext';
import { ColumnRef } from '../refs/ColumnRef';
import { createRefContext } from '../refs/RefContext';
import { col, from } from '../tests/generated';
import { resolveReferences } from './resolveReferences';
import { from } from '../tests/generated';

describe('resolveReferences', () => {
test('should resolve references', async () => {
Expand Down
3 changes: 1 addition & 2 deletions packages/backend/src/tests/benchmarks/bench.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { col } from '@synthql/queries';
import Benchmark from 'benchmark';
import fs from 'fs';
import path from 'path';
import { describe, test } from 'vitest';
import { collectLast } from '../..';
import { from } from '../generated';
import { col, from } from '../generated';
import { queryEngine } from '../queryEngine';

describe('Benchmark tests', () => {
Expand Down
19 changes: 19 additions & 0 deletions packages/backend/src/tests/e2e/defer.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { describe, test } from 'vitest';
import { col } from '../generated';
import { from } from '../queries';

describe('defer', () => {
test('top level defer', async () => {
const language = from('language')
.columns('name')
.defer()
.where({
language_id: col('film.film_id'),
})
.all();

from('film').columns('film_id').include({
language,
});
});
});
4 changes: 2 additions & 2 deletions packages/backend/src/tests/e2e/nx1.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Where, col } from '@synthql/queries';
import { Where } from '@synthql/queries';
import { describe, expect, test } from 'vitest';
import { collectLast } from '../..';
import { execute } from '../../execution/execute';
import { QueryProviderExecutor } from '../../execution/executors/QueryProviderExecutor';
import { DB, from } from '../generated';
import { col, DB, from } from '../generated';
import { provideFilm } from '../provideFilm';
import { provideLanguage } from '../provideLanguage';

Expand Down
4 changes: 2 additions & 2 deletions packages/backend/src/tests/e2e/nxm.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { col } from '@synthql/queries';
import {} from '@synthql/queries';
import { describe, expect, test } from 'vitest';
import { collectLast } from '../..';
import { execute } from '../../execution/execute';
Expand All @@ -7,7 +7,7 @@ import { createExecutionPlan } from '../../execution/planning/createExecutionPla
import { simplifyPlan } from '../../execution/planning/simplifyPlan';
import { describeQuery } from '../../query/describeQuery';
import { compareInventory } from '../compareInventory';
import { from } from '../generated';
import { col, from } from '../generated';

import { sql } from '../postgres';
import { pool } from '../queryEngine';
Expand Down
3 changes: 2 additions & 1 deletion packages/backend/src/tests/e2e/select.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Query, col } from '@synthql/queries';
import { Query } from '@synthql/queries';
import { describe, expect, test } from 'vitest';
import { collectLast } from '../..';
import { col } from '../generated';
import { sql } from '../postgres';
import { findActorById, findCityById, from, movie } from '../queries';
import { queryEngine } from '../queryEngine';
Expand Down
4 changes: 2 additions & 2 deletions packages/backend/src/tests/e2e/store-with-customers.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { QueryResult, col } from '@synthql/queries';
import { QueryResult } from '@synthql/queries';
import { describe, expect, test } from 'vitest';
import { collectLast } from '../..';
import { execute } from '../../execution/execute';
import { PgExecutor } from '../../execution/executors/PgExecutor';
import { describeQuery } from '../../query/describeQuery';
import { assertPresent } from '../../util/asserts/assertPresent';
import { from } from '../generated';
import { col, from } from '../generated';
import { sql } from '../postgres';
import { store } from '../queries.v2';
import { pool } from '../queryEngine';
Expand Down
3 changes: 2 additions & 1 deletion packages/backend/src/tests/e2e/store-with-films.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { QueryResult, col } from '@synthql/queries';
import { QueryResult } from '@synthql/queries';
import { describe, expect, test } from 'vitest';
import { collectLast } from '../..';
import { execute } from '../../execution/execute';
import { PgExecutor } from '../../execution/executors/PgExecutor';
import { describeQuery } from '../../query/describeQuery';
import { assertPresent } from '../../util/asserts/assertPresent';
import { compareInventory } from '../compareInventory';
import { col } from '../generated';
import { sql } from '../postgres';
import { from } from '../queries';
import { actor, filmActor } from '../queries.v2';
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/tests/generated/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ import { DB } from './db';
import { schema } from './schema';
export type { DB } from './db';
export { schema } from './schema';
export const from = query<DB>(schema).from;
export const { from, ref, col } = query<DB>(schema);
4 changes: 2 additions & 2 deletions packages/backend/src/tests/queries.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Table, WhereClause, col, query } from '@synthql/queries';
import { DB, schema } from './generated';
import { Table, WhereClause, query } from '@synthql/queries';
import { DB, col, schema } from './generated';

export function from<TTable extends Table<DB>>(table: TTable) {
return query<DB>(schema).from(table);
Expand Down
3 changes: 1 addition & 2 deletions packages/backend/src/tests/queries.v2.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { col } from '@synthql/queries';
import { from } from './generated';
import { col, from } from './generated';

export function language() {
return from('language').columns('name', 'language_id');
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/types/QueryProviderInput.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Table, ColumnValue } from '@synthql/queries';
import { ColumnValue, Table } from '@synthql/queries';

/**
* Get all the `whereable` columns in a table and return
Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/types/CliConfig.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ColumnDefProperties } from '@synthql/queries';

export interface CliConfig {
/**
* Internal. DO NOT USE/SET this option.
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/validators/createTableDefTransformers.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { ColumnDefProperties } from '@synthql/queries';
import { SchemaDefOverrides } from '../types/CliConfig';
import {
TableColumn,
TableDetails,
ViewColumn,
ViewDetails,
} from 'extract-pg-schema';
import { SchemaDefOverrides } from '../types/CliConfig';

interface TableDefTransformer {
test: (tableDetails: TableDetails | ViewDetails) => boolean;
Expand Down
2 changes: 1 addition & 1 deletion packages/docs/static/reference/assets/navigation.js

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

Loading

0 comments on commit dc7c8a7

Please sign in to comment.