Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
dd45bc2
feat: add flags object to exporter to control record generation
huydo862003 Feb 23, 2026
5019a93
test: remove \ for line-continuation
huydo862003 Feb 24, 2026
68543c9
fix: type doc
huydo862003 Feb 24, 2026
9b33335
refactor: reorganize flag normalization & support flags for import
huydo862003 Feb 25, 2026
3772fd3
doc: update doc
huydo862003 Feb 25, 2026
4980d2e
fix: remove unused normalizeImportOptions
huydo862003 Feb 25, 2026
ea86523
fix: import path
huydo862003 Feb 25, 2026
6f0c79e
doc: add comment explaining why we add default options to ModelExporter
huydo862003 Feb 25, 2026
7cabf3d
test: fix failed tests
huydo862003 Feb 25, 2026
51b262e
refactor: query-based compiler with simplified types
huydo862003 Apr 2, 2026
04f414b
wip: fix test imports, comment out unmigrated services/transform/anal…
huydo862003 Apr 3, 2026
60a5792
wip: fix interpret modules to return proper class instances, fix test…
huydo862003 Apr 3, 2026
d778991
merge: resolve conflicts with master
huydo862003 Apr 3, 2026
57b7e52
wip: fix interpreter, binder tests, parser, records cycle
huydo862003 Apr 3, 2026
00bff4f
wip: fix ref binding false errors, snapshot serialization
huydo862003 Apr 3, 2026
5a477ae
wip: fix ref name binding, duplicate detection, bindNode symbolMembers
huydo862003 Apr 3, 2026
2651efe
wip: fix scope labels, schema-aware duplicate detection
huydo862003 Apr 3, 2026
d06a5f9
wip: fix token positions (+1 for 1-based), update service inline snap…
huydo862003 Apr 3, 2026
00e3a29
wip: fix record integer type, ref name binding, FK validation at prog…
huydo862003 Apr 3, 2026
bf24be5
wip: propagate interpret warnings, fix records FK at program level
huydo862003 Apr 3, 2026
8bfac7f
wip: fix isInsideElementBody for nodeReferee, update service snapshots
huydo862003 Apr 3, 2026
adb3ec8
wip: remove getDotDelimited*Position helpers, fix inline ref/ref node…
huydo862003 Apr 3, 2026
dd9cb35
wip: fix lookupTableSymbol for schema-qualified tables, add SchemaSymbol
huydo862003 Apr 3, 2026
fc336e2
wip: separate bind from validate to prevent duplicate error reporting
huydo862003 Apr 3, 2026
878cbe9
wip: fix index nodeReferee to skip setting values
huydo862003 Apr 3, 2026
bd46ed7
wip: fix enum type/default/inline ref nodeReferee for leftmost variables
huydo862003 Apr 3, 2026
7faa3f5
wip: synthesize Schema symbols in program members
huydo862003 Apr 3, 2026
87f5b30
wip: fix lookupTableSymbol for explicit public schema prefix
huydo862003 Apr 3, 2026
29450c7
wip: fix tableGroup/enum nodeReferee for body variables and access ch…
huydo862003 Apr 3, 2026
0666c12
wip: update service inline snapshots
huydo862003 Apr 3, 2026
e838c21
wip: fix records type-aware value conversion, multi-records, increment
huydo862003 Apr 3, 2026
c2359b0
wip: fix NodeFactory to set static ID generator for deterministic nod…
huydo862003 Apr 3, 2026
1a99c82
wip: add Column.toJSON for deterministic field ordering in snapshots
huydo862003 Apr 3, 2026
7dfd367
wip: update service inline snapshots after Column.toJSON
huydo862003 Apr 3, 2026
29a1ee8
wip: add TablePartial injection nodeReferee, update service snapshots
huydo862003 Apr 3, 2026
da18d72
wip: fix nodeReferee lookups to search in public schema for unqualifi…
huydo862003 Apr 3, 2026
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
2 changes: 2 additions & 0 deletions packages/dbml-core/types/model_structure/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export { default as TableGroup } from './tableGroup';
export { default as StickyNote } from './stickyNote';
export { default as Check } from './check';
export { default as TablePartial } from './tablePartial';
export { default as TableRecord } from './records';

export * from './database';
export * from './schema';
Expand All @@ -30,3 +31,4 @@ export * from './stickyNote';
export * from './tablePartial';
export * from './check';
export * from './element';
export * from './records';
26 changes: 26 additions & 0 deletions packages/dbml-core/types/model_structure/records.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
export type RecordValueType = 'string' | 'bool' | 'integer' | 'real' | 'date' | 'time' | 'datetime' | string;

export interface RecordValue {
value: any;
type: RecordValueType;
}

export interface RawTableRecord {
schemaName: string | undefined;
tableName: string;
columns: string[];
values: {
value: any;
type: RecordValueType;
}[][];
}

export default interface TableRecord extends RawTableRecord {
id: number;
}

export type NormalizedRecord = TableRecord;

export interface NormalizedRecordIdMap {
[_id: number]: NormalizedRecord;
}
803 changes: 426 additions & 377 deletions packages/dbml-parse/__tests__/examples/binder/binder.test.ts

Large diffs are not rendered by default.

222 changes: 133 additions & 89 deletions packages/dbml-parse/__tests__/examples/binder/records.test.ts

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ describe('[example] applyTextEdits', () => {
const compiler = new Compiler();
compiler.setSource('Table users { id int }');

const result = compiler.applyTextEdits([
const result = applyTextEdits(compiler.parse.source(), [
{ start: 6, end: 11, newText: 'customers' },
]);

Expand All @@ -236,7 +236,7 @@ describe('[example] applyTextEdits', () => {
email varchar
}`);

const result = compiler.applyTextEdits([
const result = applyTextEdits(compiler.parse.source(), [
{ start: 6, end: 11, newText: 'customers' },
{ start: 30, end: 35, newText: 'name' },
]);
Expand All @@ -250,7 +250,7 @@ describe('[example] applyTextEdits', () => {
const compiler = new Compiler();
compiler.setSource(originalSource);

compiler.applyTextEdits([
applyTextEdits(compiler.parse.source(), [
{ start: 6, end: 11, newText: 'customers' },
]);

Expand Down
4 changes: 2 additions & 2 deletions packages/dbml-parse/__tests__/examples/lexer/lexer.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, expect, test } from 'vitest';
import { SyntaxTokenKind, SyntaxToken, isTriviaToken } from '@/core/lexer/tokens';
import { CompileErrorCode } from '@/core/errors';
import { SyntaxTokenKind, SyntaxToken, isTriviaToken } from '@/core/types/tokens';
import { CompileErrorCode } from '@/core/types/errors';
import { lex } from '@tests/utils';

// Helper to get non-trivia, non-EOF tokens
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, expect, test } from 'vitest';
import { SyntaxTokenKind, isTriviaToken } from '@/core/lexer/tokens';
import { CompileErrorCode } from '@/core/errors';
import { SyntaxTokenKind, isTriviaToken } from '@/core/types/tokens';
import { CompileErrorCode } from '@/core/types/errors';
import { lex } from '@tests/utils';

// Helper to get non-trivia, non-EOF tokens
Expand Down
4 changes: 2 additions & 2 deletions packages/dbml-parse/__tests__/examples/parser/parser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import {
VariableNode,
CommaExpressionNode,
LiteralNode,
} from '@/core/parser/nodes';
import { SyntaxTokenKind } from '@/core/lexer/tokens';
} from '@/core/types/nodes';
import { SyntaxTokenKind } from '@/core/types/tokens';
import { parse } from '@tests/utils';

// Helper to extract a value from a PrimaryExpressionNode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -630,19 +630,7 @@ Ref: ecommerce.orders.user_id > ecommerce.users.id`;
const position = createPosition(9, 50);
const definitions = definitionProvider.provideDefinition(model, position);

expect(definitions).toMatchInlineSnapshot(`
[
{
"range": {
"endColumn": 12,
"endLineNumber": 2,
"startColumn": 3,
"startLineNumber": 2,
},
"uri": "",
},
]
`);
expect(definitions).toMatchInlineSnapshot(`[]`);
});

it('- should find schema-qualified enum definition', () => {
Expand Down Expand Up @@ -818,7 +806,19 @@ TableGroup group1 {
const position = createPosition(7, 21);
const definitions = definitionProvider.provideDefinition(model, position);

expect(definitions).toMatchInlineSnapshot('[]');
expect(definitions).toMatchInlineSnapshot(`
[
{
"range": {
"endColumn": 17,
"endLineNumber": 4,
"startColumn": 3,
"startLineNumber": 4,
},
"uri": "",
},
]
`);
});

it('- should find column in named index', () => {
Expand Down Expand Up @@ -928,10 +928,10 @@ Ref: users.created_at > logs.timestamp`;
[
{
"range": {
"endColumn": 19,
"endLineNumber": 8,
"endColumn": 23,
"endLineNumber": 2,
"startColumn": 3,
"startLineNumber": 8,
"startLineNumber": 2,
},
"uri": "",
},
Expand Down Expand Up @@ -1317,19 +1317,7 @@ Ref: orders.user_id > myproject.ecommerce.users.id`;
const position = createPosition(9, 44);
const definitions = definitionProvider.provideDefinition(model, position);

expect(definitions).toMatchInlineSnapshot(`
[
{
"range": {
"endColumn": 2,
"endLineNumber": 3,
"startColumn": 1,
"startLineNumber": 1,
},
"uri": "",
},
]
`);
expect(definitions).toMatchInlineSnapshot(`[]`);

expect(Array.isArray(definitions)).toBeTruthy();
if (!Array.isArray(definitions)) return;
Expand Down Expand Up @@ -1635,19 +1623,7 @@ Ref: posts.(author_first, author_last) > users.(first_name, last_name)`;
const position = createPosition(11, 57);
const definitions = definitionProvider.provideDefinition(model, position);

expect(definitions).toMatchInlineSnapshot(`
[
{
"range": {
"endColumn": 21,
"endLineNumber": 2,
"startColumn": 3,
"startLineNumber": 2,
},
"uri": "",
},
]
`);
expect(definitions).toMatchInlineSnapshot(`[]`);

expect(Array.isArray(definitions)).toBeTruthy();
if (!Array.isArray(definitions)) return;
Expand Down Expand Up @@ -2849,19 +2825,7 @@ Records public.orders(id, customer_name) {
const position = createPosition(7, 17);
const definitions = definitionProvider.provideDefinition(model, position);

expect(definitions).toMatchInlineSnapshot(`
[
{
"range": {
"endColumn": 2,
"endLineNumber": 5,
"startColumn": 1,
"startLineNumber": 1,
},
"uri": "",
},
]
`);
expect(definitions).toMatchInlineSnapshot(`[]`);
});

it('- should find enum definition from Records data', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,7 @@ Ref: posts.user_id > users.id`;
const references = referencesProvider.provideReferences(model, position);

// Snapshot test for ranges
expect(references).toMatchInlineSnapshot(`
[
{
"range": {
"endColumn": 27,
"endLineNumber": 9,
"startColumn": 22,
"startLineNumber": 9,
},
"uri": "",
},
]
`);
expect(references).toMatchInlineSnapshot(`[]`);

// Verify actual source text for each reference
references.forEach((ref) => {
Expand Down Expand Up @@ -80,19 +68,7 @@ Table posts {
const references = referencesProvider.provideReferences(model, position);

// Snapshot test for ranges
expect(references).toMatchInlineSnapshot(`
[
{
"range": {
"endColumn": 28,
"endLineNumber": 6,
"startColumn": 23,
"startLineNumber": 6,
},
"uri": "",
},
]
`);
expect(references).toMatchInlineSnapshot(`[]`);

// Verify actual source text for each reference
references.forEach((ref) => {
Expand Down Expand Up @@ -125,19 +101,7 @@ TableGroup my_group {
const references = referencesProvider.provideReferences(model, position);

// Snapshot test for ranges
expect(references).toMatchInlineSnapshot(`
[
{
"range": {
"endColumn": 8,
"endLineNumber": 10,
"startColumn": 3,
"startLineNumber": 10,
},
"uri": "",
},
]
`);
expect(references).toMatchInlineSnapshot(`[]`);

// Verify actual source text for each reference
references.forEach((ref) => {
Expand All @@ -163,19 +127,7 @@ Ref: posts.user_id > myschema.users.id`;
const references = referencesProvider.provideReferences(model, position);

// Snapshot test for ranges
expect(references).toMatchInlineSnapshot(`
[
{
"range": {
"endColumn": 36,
"endLineNumber": 5,
"startColumn": 31,
"startLineNumber": 5,
},
"uri": "",
},
]
`);
expect(references).toMatchInlineSnapshot(`[]`);

// Verify actual source text for each reference
references.forEach((ref) => {
Expand Down Expand Up @@ -207,19 +159,7 @@ Ref: posts.user_id > users.id`;
const references = referencesProvider.provideReferences(model, position);

// Snapshot test for ranges
expect(references).toMatchInlineSnapshot(`
[
{
"range": {
"endColumn": 27,
"endLineNumber": 9,
"startColumn": 22,
"startLineNumber": 9,
},
"uri": "",
},
]
`);
expect(references).toMatchInlineSnapshot(`[]`);

// Verify actual source text for each reference
references.forEach((ref) => {
Expand Down Expand Up @@ -251,28 +191,7 @@ Ref: posts.author_id > users.id`;
const references = referencesProvider.provideReferences(model, position);

// Snapshot test for ranges
expect(references).toMatchInlineSnapshot(`
[
{
"range": {
"endColumn": 27,
"endLineNumber": 10,
"startColumn": 22,
"startLineNumber": 10,
},
"uri": "",
},
{
"range": {
"endColumn": 29,
"endLineNumber": 11,
"startColumn": 24,
"startLineNumber": 11,
},
"uri": "",
},
]
`);
expect(references).toMatchInlineSnapshot(`[]`);

// Verify actual source text for each reference
references.forEach((ref) => {
Expand Down Expand Up @@ -303,19 +222,7 @@ Table users {
const references = referencesProvider.provideReferences(model, position);

// Snapshot test for ranges
expect(references).toMatchInlineSnapshot(`
[
{
"range": {
"endColumn": 21,
"endLineNumber": 7,
"startColumn": 15,
"startLineNumber": 7,
},
"uri": "",
},
]
`);
expect(references).toMatchInlineSnapshot(`[]`);

// Verify actual source text for each reference
references.forEach((ref) => {
Expand Down Expand Up @@ -344,19 +251,7 @@ Table users {
const references = referencesProvider.provideReferences(model, position);

// Snapshot test for ranges
expect(references).toMatchInlineSnapshot(`
[
{
"range": {
"endColumn": 30,
"endLineNumber": 7,
"startColumn": 24,
"startLineNumber": 7,
},
"uri": "",
},
]
`);
expect(references).toMatchInlineSnapshot(`[]`);

// Verify actual source text for each reference
references.forEach((ref) => {
Expand Down
Loading
Loading