Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQLite onConflict chaining fix #4028

Merged
merged 4 commits into from
Jan 29, 2025
Merged

SQLite onConflict chaining fix #4028

merged 4 commits into from
Jan 29, 2025

Conversation

Sukairo-02
Copy link
Collaborator

@Sukairo-02 Sukairo-02 commented Jan 28, 2025

  • Fixed SQLite onConflict clauses being overwritten instead of stacked (fixes [FEATURE]: Support multiple onConflictDoUpdate's #2276)
  • Added related tests
  • Removed unused import
  • Fixed joined views not generating proper types in MySQL and PostgreSQL
  • Added view support to aliasedTable() function (requested in [FEATURE]: Ability to use an aliased view #3491)
  • Made aliasedTable() function same as alias() functions on type-level (fixes aliasedTable() not aliasing tables on type level) - removed in favor of dialect-specific alias() functions
  • Fixed sql builder prefixing aliased views and tables with their schema

@L-Mario564
Copy link
Collaborator

@Sukairo-02 Probably worth mentioning that this RP would close #2276.

…es on type level, added `View` support to `aliasedTable()`, fixed sql builder prefixing aliased views and tables with their schema names
@L-Mario564
Copy link
Collaborator

And #3491 too.

@@ -88,8 +93,15 @@ export class RelationTableAliasProxyHandler<T extends Relation> implements Proxy
}
}

export function aliasedTable<T extends Table>(table: T, tableAlias: string): T {
return new Proxy(table, new TableAliasProxyHandler(tableAlias, false));
export function aliasedTable<T extends Table | View, TAlias extends string>(
Copy link
Member

Choose a reason for hiding this comment

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

maybe we need to separate it to each dialect

const sqlitevUsers = sqliteView('users_view').as((qb) => qb.select().from(sqliteUsers));
const mysqlvUsers = mysqlView('users_view').as((qb) => qb.select().from(mysqlUsers));

const pgAlias = aliasedTable(pgUsers, 'usersAlias');
Copy link
Member

Choose a reason for hiding this comment

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

test just alias

@AndriiSherman AndriiSherman merged commit 3cd4f9f into beta Jan 29, 2025
8 checks passed
@AndriiSherman AndriiSherman deleted the on-conflict-chaining-fix branch January 29, 2025 13:19
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.

3 participants