Fix quotes with schema default values (#6968)

* Added quote trimming to schema default values

* Add return type to stripQuotes function

Co-authored-by: rijkvanzanten <rijkvanzanten@me.com>
This commit is contained in:
Aiden Foxx
2021-07-26 18:37:45 +02:00
committed by GitHub
parent 961bc80e13
commit 27037f95c7
3 changed files with 20 additions and 2 deletions

View File

@@ -3,6 +3,7 @@ import extractMaxLength from 'knex-schema-inspector/dist/utils/extract-max-lengt
import extractType from 'knex-schema-inspector/dist/utils/extract-type';
import { SchemaOverview } from '../types/overview';
import { SchemaInspector } from '../types/schema';
import { stripQuotes } from '../utils/strip-quotes';
type RawColumn = {
cid: number;
@@ -39,7 +40,7 @@ export default class SQLite extends KnexSQLite implements SchemaInspector {
default_value:
column.pk === 1 && tablesWithAutoIncrementPrimaryKeys.includes(table)
? 'AUTO_INCREMENT'
: column.dflt_value,
: stripQuotes(column.dflt_value),
is_nullable: column.notnull == 0,
data_type: extractType(column.type),
max_length: extractMaxLength(column.type),