Skip to content

Commit

Permalink
update sqlite setColumnID
Browse files Browse the repository at this point in the history
  • Loading branch information
r1tsuu committed Jan 1, 2025
1 parent a9e7337 commit e94b2f7
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions packages/db-sqlite/src/schema/setColumnID.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,17 @@ import type { SQLiteAdapter } from '../types.js'

export const setColumnID: SetColumnID = ({ adapter, columns, fields }) => {
const idField = fields.find((field) => field.name === 'id')

let name: string = 'id'

if (idField && (idField.type === 'number' || idField.type === 'text') && idField.dbColumnName) {
name = idField.dbColumnName
}

if (idField) {
if (idField.type === 'number') {
columns.id = {
name: 'id',
name,
type: 'numeric',
primaryKey: true,
}
Expand All @@ -16,7 +23,7 @@ export const setColumnID: SetColumnID = ({ adapter, columns, fields }) => {

if (idField.type === 'text') {
columns.id = {
name: 'id',
name,
type: 'text',
primaryKey: true,
}
Expand All @@ -26,7 +33,7 @@ export const setColumnID: SetColumnID = ({ adapter, columns, fields }) => {

if (adapter.idType === 'uuid') {
columns.id = {
name: 'id',
name,
type: 'uuid',
defaultRandom: true,
primaryKey: true,
Expand Down

0 comments on commit e94b2f7

Please sign in to comment.