Skip to content

Chages#2

Merged
ElectronSz merged 3 commits into
mainfrom
chages
Apr 2, 2026
Merged

Chages#2
ElectronSz merged 3 commits into
mainfrom
chages

Conversation

@ElectronSz
Copy link
Copy Markdown
Owner

No description provided.

@ElectronSz ElectronSz merged commit d7a2f5b into main Apr 2, 2026
1 check passed
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dcbdbc3f72

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread auto-migrate.ts
const rows = await db.query<any>(`PRAGMA table_info(${table});`);
return new Set(rows.map((r: any) => r.name));
case DBType.MySQL:
const cols = await db.query<any>(`SHOW COLUMNS FROM \`${table}\`;`);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Handle absent MySQL tables before column introspection

autoMigrate calls getExistingColumns before deciding whether to create a table, but the MySQL branch runs SHOW COLUMNS FROM directly; on a brand-new model table this statement errors instead of returning an empty set, so migration aborts before reaching CREATE TABLE. This breaks first-time auto-migration on MySQL databases.

Useful? React with 👍 / 👎.

Comment thread auto-migrate.ts
Comment on lines +215 to +217
if (dialect === "mysql") {
return `ALTER TABLE DROP INDEX \`${indexName}\``;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Include table name in generated MySQL DROP INDEX SQL

The MySQL drop-index SQL is missing the table identifier (ALTER TABLE DROP INDEX ...), which is invalid syntax in MySQL. Whenever autoMigrate tries to remove an obsolete index, the migration will fail at runtime instead of converging schema state.

Useful? React with 👍 / 👎.

Comment thread repository.ts
Comment on lines +608 to +610
const whereParts: string[] = ["id = ?"];
const queryParams = [...keys.map((k) => (entity as any)[k]), id];

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Bind UPDATE parameters from mutated entity state

In _update, the SET clause is built from entityWithTimestamps, but parameter values are read from the original entity. When updatedAt is auto-injected, its placeholder receives undefined, so timestamp columns are not updated correctly (and can violate NOT NULL constraints) despite being included in the SQL.

Useful? React with 👍 / 👎.

Comment thread repository.ts
Comment on lines +619 to +623
const lockColIdx = keys.findIndex(
(k) => k === this.optimisticLockField,
);
if (lockColIdx !== -1) {
queryParams[lockColIdx] = newLockVal;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Increment optimistic lock column on every successful update

The optimistic-lock field is assigned a new value only if it was already present in the user-provided update keys; otherwise keys/setClause omit it and the row version never changes. In that common path, concurrent updates with the same prior version can both succeed, defeating optimistic locking conflict detection.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant