Skip to content

Commit b878910

Browse files
committed
Refactor import statements in test files for improved readability and consistency, and update SQL query formatting to use semicolons where necessary.
1 parent 97b21b2 commit b878910

File tree

5 files changed

+37
-22
lines changed

5 files changed

+37
-22
lines changed

__tests__/insert-builder.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {InsertQueryBuilder, SqlExecutor} from "../src";
1+
import { InsertQueryBuilder, SqlExecutor } from "../src";
22

33
// Mock SqlExecutor
44
const mockExecutor: SqlExecutor = {

__tests__/schema.test.ts

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1-
import {Table} from "../src/schema";
2-
import {integer, serial, text, timestamp, uuid, varchar} from "../src/types/column-type";
1+
import { Table } from "../src/schema";
2+
import {
3+
integer,
4+
serial,
5+
text,
6+
timestamp,
7+
uuid,
8+
varchar,
9+
} from "../src/types/column-type";
310

411
// Define test interfaces
512
interface User {
@@ -41,7 +48,7 @@ describe("Schema and Table", () => {
4148
table.column("id", uuid()).primaryKey();
4249
table.column("name", varchar());
4350

44-
const sql = table.createTableSql()
51+
const sql = table.createTableSql();
4552
expect(sql).toContain(`UUID PRIMARY KEY NOT NULL`);
4653
});
4754

@@ -76,14 +83,18 @@ describe("Schema and Table", () => {
7683
// );
7784

7885
const sql = table.createTableSql();
79-
expect(sql).toContain(`"id" UUID PRIMARY KEY NOT NULL DEFAULT gen_random_uuid()`);
86+
expect(sql).toContain(
87+
`"id" UUID PRIMARY KEY NOT NULL DEFAULT gen_random_uuid()`
88+
);
8089
expect(sql).toContain(`"createdAt" TIMESTAMP DEFAULT 'now()'`);
8190
});
8291

8392
it("should create a table with foreign key references", () => {
8493
const table = new Table<Post>("posts");
8594
table.column("id", uuid()).primaryKey().$defaultUUID();
86-
table.column("authorId", uuid()).references({table: "users", column: "id", onDelete: 'CASCADE'});
95+
table
96+
.column("authorId", uuid())
97+
.references({ table: "users", column: "id", onDelete: "CASCADE" });
8798

8899
const sql = table.createTableSql();
89100
expect(sql).toContain('"authorId" UUID REFERENCES users(id)');
@@ -96,9 +107,9 @@ describe("Schema and Table", () => {
96107
table.column("email", varchar()).unique().notNull();
97108
table.column("age", integer());
98109
table
99-
.column("createdAt", timestamp())
100-
.default("CURRENT_TIMESTAMP")
101-
.notNull();
110+
.column("createdAt", timestamp())
111+
.default("CURRENT_TIMESTAMP")
112+
.notNull();
102113

103114
// CREATE TABLE IF NOT EXISTS users (
104115
// "id" UUID PRIMARY KEY NOT NULL DEFAULT gen_random_uuid(),
@@ -108,14 +119,17 @@ describe("Schema and Table", () => {
108119
// "createdAt" TIMESTAMP NOT NULL DEFAULT 'CURRENT_TIMESTAMP'
109120
// );
110121
const sql = table.createTableSql();
111-
expect(sql).toContain(`"id" UUID PRIMARY KEY NOT NULL DEFAULT gen_random_uuid()`);
122+
expect(sql).toContain(
123+
`"id" UUID PRIMARY KEY NOT NULL DEFAULT gen_random_uuid()`
124+
);
112125
expect(sql).toContain(`"name" VARCHAR(255) NOT NULL`);
113126
expect(sql).toContain(`"email" VARCHAR(255) NOT NULL UNIQUE`);
114127
expect(sql).toContain(`"age" INTEGER`);
115-
expect(sql).toContain(`"createdAt" TIMESTAMP NOT NULL DEFAULT 'CURRENT_TIMESTAMP'`);
128+
expect(sql).toContain(
129+
`"createdAt" TIMESTAMP NOT NULL DEFAULT 'CURRENT_TIMESTAMP'`
130+
);
116131
});
117132

118-
119133
it("should handle complex table relationships", () => {
120134
const usersTable = new Table<User>("users");
121135
usersTable.column("id", uuid()).primaryKey();
@@ -128,12 +142,9 @@ describe("Schema and Table", () => {
128142
postsTable.column("authorId", uuid()).notNull().references({
129143
table: "users",
130144
column: "id",
131-
onDelete: 'CASCADE'
145+
onDelete: "CASCADE",
132146
});
133-
postsTable
134-
.column("createdAt", timestamp())
135-
.$defaultNOW()
136-
.notNull();
147+
postsTable.column("createdAt", timestamp()).$defaultNOW().notNull();
137148

138149
const postsSql = postsTable.createTableSql();
139150

@@ -145,8 +156,12 @@ describe("Schema and Table", () => {
145156
// "createdAt" TIMESTAMP NOT NULL DEFAULT 'now()'
146157
// );
147158

148-
expect(postsSql).toContain(`"authorId" UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE`);
149-
expect(postsSql).toContain(`"createdAt" TIMESTAMP NOT NULL DEFAULT 'now()'`);
159+
expect(postsSql).toContain(
160+
`"authorId" UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE`
161+
);
162+
expect(postsSql).toContain(
163+
`"createdAt" TIMESTAMP NOT NULL DEFAULT 'now()'`
164+
);
150165
});
151166
});
152167
});

src/operators/comparison.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { SimpleWhere } from "../types/query";
1+
import { SimpleWhere } from "../types";
22

33
// Equal
44
export function eq<T, K extends keyof T>(key: K, value: T[K]): SimpleWhere<T> {

src/operators/logical.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { CompositeWhere, WhereCondition } from "../types/query";
1+
import { CompositeWhere, WhereCondition } from "../types";
22

33
// Logical AND
44
export function and<T>(

src/operators/sorting.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { OrderBy } from "../types/query";
1+
import { OrderBy } from "../types";
22

33
// Ascending order
44
export function asc<T>(key: keyof T): OrderBy<T> {

0 commit comments

Comments
 (0)