@balena/abstract-sql-compiler
Advanced tools
Comparing version 7.4.0-definitions-480da0c6225ce0eb484522f6d3a65e31b47bd88b to 7.4.0
@@ -153,6 +153,6 @@ export declare const enum Engines { | ||
} | ||
export declare type Definition = FromTypeNodes | { | ||
export interface Definition { | ||
binds?: BindVars; | ||
abstractSql: FromTypeNodes; | ||
}; | ||
} | ||
export interface AbstractSqlTable { | ||
@@ -159,0 +159,0 @@ name: string; |
@@ -243,12 +243,6 @@ "use strict"; | ||
if (definition != null) { | ||
let definitionAbstractSql; | ||
if (Array.isArray(definition)) { | ||
definitionAbstractSql = definition; | ||
if (definition.binds != null && definition.binds.length > 0) { | ||
return; | ||
} | ||
else { | ||
if (definition.binds != null && definition.binds.length > 0) { | ||
return; | ||
} | ||
definitionAbstractSql = definition.abstractSql; | ||
} | ||
let definitionAbstractSql = definition.abstractSql; | ||
if (containsNode(definitionAbstractSql, exports.isResourceNode)) { | ||
@@ -255,0 +249,0 @@ return; |
{ | ||
"name": "@balena/abstract-sql-compiler", | ||
"version": "7.4.0-definitions-480da0c6225ce0eb484522f6d3a65e31b47bd88b", | ||
"version": "7.4.0", | ||
"description": "A translator for abstract sql into sql.", | ||
@@ -5,0 +5,0 @@ "main": "out/AbstractSQLCompiler.js", |
@@ -256,8 +256,6 @@ export const enum Engines { | ||
} | ||
export type Definition = | ||
| FromTypeNodes | ||
| { | ||
binds?: BindVars; | ||
abstractSql: FromTypeNodes; | ||
}; | ||
export interface Definition { | ||
binds?: BindVars; | ||
abstractSql: FromTypeNodes; | ||
} | ||
export interface AbstractSqlTable { | ||
@@ -677,12 +675,7 @@ name: string; | ||
if (definition != null) { | ||
let definitionAbstractSql; | ||
if (Array.isArray(definition)) { | ||
definitionAbstractSql = definition; | ||
} else { | ||
if (definition.binds != null && definition.binds.length > 0) { | ||
// If there are any binds then it's a dynamic definition and cannot become a view | ||
return; | ||
} | ||
definitionAbstractSql = definition.abstractSql; | ||
if (definition.binds != null && definition.binds.length > 0) { | ||
// If there are any binds then it's a dynamic definition and cannot become a view | ||
return; | ||
} | ||
let definitionAbstractSql = definition.abstractSql; | ||
// If there are any resource nodes then it's a dynamic definition and cannot become a view | ||
@@ -689,0 +682,0 @@ if ( |
@@ -23,37 +23,2 @@ import * as AbstractSQLCompiler from '../..'; | ||
primitive: false, | ||
definition: ['Table', 'other table'], | ||
}, | ||
}, | ||
rules: [], | ||
}), | ||
) | ||
.to.have.property('createSchema') | ||
.that.deep.equals([ | ||
`\ | ||
CREATE OR REPLACE VIEW "test" AS ( | ||
SELECT * | ||
FROM "other table" | ||
);`, | ||
]); | ||
}); | ||
it('a table with a static object based definition should produce a view', () => { | ||
expect( | ||
AbstractSQLCompiler.postgres.compileSchema({ | ||
synonyms: {}, | ||
relationships: {}, | ||
tables: { | ||
test: { | ||
name: 'test', | ||
resourceName: 'test', | ||
idField: 'id', | ||
fields: [ | ||
{ | ||
fieldName: 'id', | ||
dataType: 'Integer', | ||
index: 'PRIMARY KEY', | ||
}, | ||
], | ||
indexes: [], | ||
primitive: false, | ||
definition: { abstractSql: ['Table', 'other table'] }, | ||
@@ -60,0 +25,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1
560464
12275