import _ from "lodash" ; import { addTicks , DialectOptions , FKRow } from "./dialect-options" ; export const sqliteOptions = { name : 'sqlite' , hasSchema : false , param { String } tableName return { String } getForeignKeysQuery : ( tableName , schemaName ) => { return `PRAGMA foreign_key_list(\`${ tableName }\`);` ; } , param { String } tableName param { Object } row remapForeignKeysRow : ( tableName , row ) => { return { constraint_name : `${ tableName }_${ row . id }` , source_schema : undefined , source_table : tableName , source_column : row . from , target_schema : undefined , target_table : row . table , target_column : row . to } ; } , param { String } tableName param { String } schemaName return { String } countTriggerQuery : ( tableName , schemaName ) => { return `SELECT COUNT(0) AS trigger_count
              FROM sqlite_master
             WHERE type = 'trigger'
               AND tbl_name = ${ addTicks ( tableName ) }` ; } , param { Object } record return { Bool } isPrimaryKey : ( record ) => { return _ . isObject ( record ) && _ . has ( record , 'primaryKey' ) && record . primaryKey === true ; } , param { Object } record return { Bool } isSerialKey : ( record ) => { return ( _ . isObject ( record ) && sqliteOptions . isPrimaryKey ( record ) && ( ! ! record . type && record . type . toUpperCase ( ) === 'INTEGER' ) ) ; } , showViewsQuery : ( ) => { return `SELECT name FROM "sqlite_master" WHERE type='view'` ; } } ;