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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

minor fix: bool should not be empty when there is not null constraint #1711

Merged
merged 5 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 9 additions & 3 deletions apps/studio/src/components/tableview/TableTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -646,15 +646,21 @@ export default Vue.extend({
editorParams: {
verticalNavigation: useVerticalNavigation ? 'editor' : undefined,
search: true,
values: /^(bool|boolean)$/i.test(column.dataType)
? [true, false]
: undefined,
allowEmpty: true,
// elementAttributes: {
// maxLength: column.columnLength // TODO
// }
},
}

if (/^(bool|boolean)$/i.test(column.dataType)) {
const trueVal = this.dialectData.boolean?.true ?? true
const falseVal = this.dialectData.boolean?.false ?? false
const values = [falseVal, trueVal]
if (column.nullable) values.push({ label: '(NULL)', value: null })
result.editorParams['values'] = values
}

results.push(result)

if (keyDatas && keyDatas.length > 0) {
Expand Down
4 changes: 4 additions & 0 deletions shared/src/lib/dialects/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ export interface DialectData {
query?: string
},
charsets?: string[]|null
boolean?: {
true: any
false: any
}
}

export const defaultConstraintActions = [
Expand Down
6 changes: 5 additions & 1 deletion shared/src/lib/dialects/sqlite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,9 @@ export const SqliteData: DialectData = {
},
notices: {
infoSchema: "Note: SQLite does not support any column alterations except renaming"
}
},
boolean: {
true: BigInt(1),
false: BigInt(0),
},
}