Skip to content

Commit b6a91c5

Browse files
committed
feat(sql-orm-client): add User↔Tag M:N fixture via UserTag junction; re-emit contract
Adds a pure-junction UserTag model (userId/tagId, composite PK) and a User.tags manyToMany relation to the sql-orm-client integration fixture. Re-emits contract.json + contract.d.ts for both the integration test copy and the package-local copy (with pgvector refs stripped). The Tag model stays single-sided (no Tag.users reverse) to avoid a MutationCreateInputWithRelations overload collision in the existing collection-mutation-defaults tests. Emitted via tsx script (c12 config loader unavailable in this sandbox); verified additivity of the diff and round-trip via SqlContractSerializer. Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
1 parent 13816af commit b6a91c5

5 files changed

Lines changed: 355 additions & 4 deletions

File tree

packages/3-extensions/sql-orm-client/test/fixtures/generated/contract.d.ts

Lines changed: 84 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/3-extensions/sql-orm-client/test/fixtures/generated/contract.json

Lines changed: 85 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/integration/test/sql-orm-client/fixtures/contract.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,17 @@ const Tag = model('Tag', {
6464
},
6565
}).sql({ table: 'tags' });
6666

67+
const UserTag = model('UserTag', {
68+
fields: {
69+
userId: field.column(int4Column).column('user_id'),
70+
tagId: field.column(textColumn).column('tag_id'),
71+
},
72+
})
73+
.attributes(({ fields, constraints }) => ({
74+
id: constraints.id([fields.userId, fields.tagId]),
75+
}))
76+
.sql({ table: 'user_tags' });
77+
6778
const Post = PostBase.relations({
6879
comments: rel.hasMany(() => Comment, { by: 'postId' }),
6980
author: rel.belongsTo(UserBase, { from: 'userId', to: 'id' }).sql({ fk: {} }),
@@ -74,6 +85,11 @@ const User = UserBase.relations({
7485
invitedBy: rel.belongsTo(UserBase, { from: 'invitedById', to: 'id' }).sql({ fk: {} }),
7586
posts: rel.hasMany(() => Post, { by: 'userId' }),
7687
profile: rel.hasOne(() => Profile, { by: 'userId' }),
88+
tags: rel.manyToMany(() => Tag, {
89+
through: () => UserTag,
90+
from: 'userId',
91+
to: 'tagId',
92+
}),
7793
}).sql({ table: 'users' });
7894

7995
const baseContract = defineContract({
@@ -85,6 +101,7 @@ const baseContract = defineContract({
85101
Profile,
86102
Article,
87103
Tag,
104+
UserTag,
88105
},
89106
});
90107

0 commit comments

Comments
 (0)