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
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';

import { readSqlDriverSource } from '../../../../scripts/sql-driver-split-source.mjs';
import { describe, expect, it } from 'vitest';

import { generateMigrationSql, generateMigrationTs } from './generate.js';
Expand All @@ -99,7 +100,9 @@ const GENERATE_SOURCE = fs.readFileSync(GENERATE_TS, 'utf8');

/** The authority, read where it lives — never transcribed here. */
const DRIVER_SQL_SRC = path.resolve(HERE, '../../../drivers/driver-sql/src');
const SQL_DRIVER_SOURCE = fs.readFileSync(path.join(DRIVER_SQL_SRC, 'sql-driver.ts'), 'utf8');
// `SqlDriver` as one text: `sql-driver.ts` with each codemod stub's body read
// from the facet module it moved to, and the leaf ahead of the class (#30147).
const SQL_DRIVER_SOURCE = readSqlDriverSource(DRIVER_SQL_SRC).text;

/** The one line the driver emits for a managed table's primary key. */
const DRIVER_ID_COLUMN = "table.string('id').primary();";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ import {
REFERENCE_VALUE_TYPES,
STRUCTURED_JSON_TYPES,
} from '@objectstack/spec/data';
import { readSqlDriverSource } from '../../../../scripts/sql-driver-split-source.mjs';
import { describe, expect, it } from 'vitest';

import { generateMigrationSql, generateMigrationTs, generateTypesFromConfig } from './generate.js';
Expand Down Expand Up @@ -318,7 +319,9 @@ describe('generate.ts field-type vocabularies (#13871)', () => {

/** `packages/drivers/driver-sql/src` — declared for `@objectstack/cli#test` in `turbo.json`. */
const DRIVER_SQL_SRC = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../../drivers/driver-sql/src');
const SQL_DRIVER_SOURCE = fs.readFileSync(path.join(DRIVER_SQL_SRC, 'sql-driver.ts'), 'utf8');
// `SqlDriver` as one text: `sql-driver.ts` with each codemod stub's body read
// from the facet module it moved to, and the leaf ahead of the class (#30147).
const SQL_DRIVER_SOURCE = readSqlDriverSource(DRIVER_SQL_SRC).text;
const SCHEMA_DRIFT_SOURCE = fs.readFileSync(path.join(DRIVER_SQL_SRC, 'schema-drift.ts'), 'utf8');

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,16 @@ import path from 'node:path';
import { fileURLToPath } from 'node:url';

import { FILE_REFERENCE_TYPES, REFERENCE_VALUE_TYPES } from '@objectstack/spec/data';
import { readSqlDriverSource } from '../../../../scripts/sql-driver-split-source.mjs';
import { describe, expect, it } from 'vitest';

import { generateMigrationSql, generateMigrationTs } from './generate.js';

/** `packages/drivers/driver-sql/src` — declared for `@objectstack/cli#test` in `turbo.json`. */
const DRIVER_SQL_SRC = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../../drivers/driver-sql/src');
const SQL_DRIVER_SOURCE = fs.readFileSync(path.join(DRIVER_SQL_SRC, 'sql-driver.ts'), 'utf8');
// `SqlDriver` as one text: `sql-driver.ts` with each codemod stub's body read
// from the facet module it moved to, and the leaf ahead of the class (#30147).
const SQL_DRIVER_SOURCE = readSqlDriverSource(DRIVER_SQL_SRC).text;

/** The control the generator documents, plus the arm the family used to ride. */
const CONTROL_TYPES = ['text', ...REFERENCE_VALUE_TYPES, 'autonumber'] as const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ import path from 'node:path';
import { fileURLToPath } from 'node:url';

import { isMultiValueField, MULTI_CAPABLE_TYPES, MULTI_OPTION_TYPES } from '@objectstack/spec/data';
import { readSqlDriverSource } from '../../../../scripts/sql-driver-split-source.mjs';
import { describe, expect, it } from 'vitest';

import {
Expand Down Expand Up @@ -377,7 +378,8 @@ describe('#14829 — `multiple: true` is one answer across all three surfaces',
// this rule, these fail and whoever moved it re-derives the generators.

it('driver-sql `createColumn` still decides `multiple` BEFORE the type switch', () => {
const source = fs.readFileSync(path.join(DRIVER_SQL_SRC, 'sql-driver.ts'), 'utf8');
// `SqlDriver` as one text, each codemod stub's body read where it moved (#30147).
const source = readSqlDriverSource(DRIVER_SQL_SRC).text;
// Non-vacuity: the file was really read, and the two landmarks really found.
expect(source.length).toBeGreaterThan(10_000);
const start = source.indexOf('protected createColumn(');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ import {
MULTI_OPTION_TYPES,
STRUCTURED_JSON_TYPES,
} from '@objectstack/spec/data';
import { readSqlDriverSource } from '../../../../scripts/sql-driver-split-source.mjs';
import { afterAll, describe, expect, it } from 'vitest';

import { generateMigrationSql, generateMigrationTs } from './generate.js';
Expand All @@ -260,7 +261,9 @@ const GENERATE_SOURCE = fs.readFileSync(path.resolve(HERE, 'generate.ts'), 'utf8

/** The authority, read where it lives — never transcribed here. */
const DRIVER_SQL_SRC = path.resolve(HERE, '../../../drivers/driver-sql/src');
const SQL_DRIVER_SOURCE = fs.readFileSync(path.join(DRIVER_SQL_SRC, 'sql-driver.ts'), 'utf8');
// `SqlDriver` as one text: `sql-driver.ts` with each codemod stub's body read
// from the facet module it moved to, and the leaf ahead of the class (#30147).
const SQL_DRIVER_SOURCE = readSqlDriverSource(DRIVER_SQL_SRC).text;
const SCHEMA_DRIFT_SOURCE = fs.readFileSync(path.join(DRIVER_SQL_SRC, 'schema-drift.ts'), 'utf8');

/** The authority for which types exist at all. Imported, never listed here. */
Expand Down
Loading
Loading