Skip to content

Resolves issue #65, Resolves Issue #67 #64

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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 36 additions & 32 deletions dist/quick-sql.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ function K(u, m, D) {
let k = u + m + D;
return R ? k = '"' + k + '"' : k = k.toLowerCase(), k;
}
function pe(u) {
let m = u.match(/^([0-9]+(?:[.][0-9]+)?)/);
return m ? m[0] : null;
}
var le = function() {
var u = [
"Sales",
Expand Down Expand Up @@ -89,7 +93,7 @@ var le = function() {
}
return R;
}();
function pe(u) {
function ge(u) {
return u && u.__esModule && Object.prototype.hasOwnProperty.call(u, "default") ? u.default : u;
}
var ie = { exports: {} };
Expand Down Expand Up @@ -7208,10 +7212,10 @@ var ie = { exports: {} };
}, u.exports && (m = u.exports = i), m.Chance = i, typeof importScripts < "u" && (chance = new i(), self.Chance = i), typeof window == "object" && typeof window.document == "object" && (window.Chance = i, window.chance = new i());
})();
})(ie, ie.exports);
var ge = ie.exports;
const Ce = /* @__PURE__ */ pe(ge);
var Ce = ie.exports;
const ve = /* @__PURE__ */ ge(Ce);
function se(u, m, D, R) {
var k = new Ce(te);
var k = new ve(te);
D == null && console.log();
let N = D.toUpperCase(), v = u.toUpperCase(), g = m.toUpperCase();
if (R != null && 0 < R.length) {
Expand Down Expand Up @@ -7254,7 +7258,7 @@ function se(u, m, D, R) {
return "'N/A'";
}
var te = 1;
function ve() {
function Ae() {
te = 1;
}
function Z() {
Expand Down Expand Up @@ -7724,7 +7728,7 @@ let ue = function() {
break;
}
const L = u.getOptionValue("db");
I != "" && (u.getOptionValue("boolean") == "native" || u.getOptionValue("boolean") != "yn" && 0 < L.length && L.charAt(0) == "2" && L.charAt(1) == "3") && (I = "", d = "boolean"), this.indexOf("phone_number") == 0 && (d = "number");
I != "" && (u.getOptionValue("boolean") == "native" || u.getOptionValue("boolean") != "yn" && 0 < L.length && 23 <= pe(L)) && (I = "", d = "boolean"), this.indexOf("phone_number") == 0 && (d = "number");
let O = this.indexOf("num", !0);
0 < O && (d = "number");
let w = this.indexOf(")");
Expand Down Expand Up @@ -8410,7 +8414,7 @@ is
}
return 0;
}, this.generateData = function(r) {
if (ve(), u.optionEQvalue("inserts", !1))
if (Ae(), u.optionEQvalue("inserts", !1))
return "";
const t = this.inserts4tbl(r), o = this.orderedTableNodes();
let s = "";
Expand Down Expand Up @@ -8656,7 +8660,7 @@ modify ` + C + " generated always as identity restart start with " + (this.card
}
return v;
}();
var Ae = function() {
var ye = function() {
function u(i) {
for (var l = "", p = 0; p < i; p++)
l = l + " ";
Expand Down Expand Up @@ -8860,7 +8864,7 @@ var Ae = function() {
}
return S;
}();
const ye = function() {
const Se = function() {
function u(g, S, E, i) {
this.from = S, this.to = E, E == null && (this.to = new m(S.line, S.depth + 1)), this.message = g, this.severity = i, i == null && (this.severity = "error");
}
Expand Down Expand Up @@ -8908,11 +8912,11 @@ const ye = function() {
continue;
}
if (p) {
p = !1, E && Se.indexOf(l[r].value.toLowerCase()) < 0 && i.push(new u(
p = !1, E && Me.indexOf(l[r].value.toLowerCase()) < 0 && i.push(new u(
Y.tableDirectiveTypo,
new m(S.line, l[r].begin),
new m(S.line, l[r].begin + l[r].value.length)
)), !E && Me.indexOf(l[r].value.toLowerCase()) < 0 && i.push(new u(
)), !E && Te.indexOf(l[r].value.toLowerCase()) < 0 && i.push(new u(
Y.columnDirectiveTypo,
new m(S.line, l[r].begin),
new m(S.line, l[r].begin + l[r].value.length)
Expand Down Expand Up @@ -8951,7 +8955,7 @@ const ye = function() {
return E;
}
function v(g) {
for (var S = [], E = Te(g), i = 1; i < g.length; i++) {
for (var S = [], E = Ie(g), i = 1; i < g.length; i++) {
var l = g[i], p = fe(l);
p % E != 0 && S.push(
new u(
Expand All @@ -8963,7 +8967,7 @@ const ye = function() {
return S;
}
return D;
}(), Se = [
}(), Me = [
"api",
"audit",
"auditcols",
Expand All @@ -8980,7 +8984,7 @@ const ye = function() {
"cascade",
"setnull"
//'set null'
], Me = [
], Te = [
"idx",
"index",
"indexed",
Expand All @@ -9002,15 +9006,15 @@ const ye = function() {
"fk",
"pk"
];
function Te(u) {
function Ie(u) {
let m = [];
for (var D = 0; D < u.length; D++) {
var R = u[D];
m[D] = fe(R);
}
let k = [];
for (let v = 0; v < m.length; v++) {
let g = Ie(m, v);
let g = Be(m, v);
if (g != null) {
let S = k[m[v] - m[g]];
S == null && (S = 0), k[m[v] - m[g]] = S + 1;
Expand All @@ -9024,7 +9028,7 @@ function Te(u) {
function fe(u) {
return u.src[0].begin;
}
function Ie(u, m) {
function Be(u, m) {
for (let D = m; 0 <= D; D--)
if (u[D] < u[m])
return D;
Expand All @@ -9037,7 +9041,7 @@ const Y = {
misalignedAttribute: "Misaligned Table or Column; apparent indent = ",
tableDirectiveTypo: "Unknown Table directive",
columnDirectiveTypo: "Unknown Column directive"
}, Be = { findErrors: ye, messages: Y }, me = "identityDataType", ne = "guid", he = "Timestamp with time zone", de = "Timestamp with local time zone", j = function() {
}, Pe = { findErrors: Se, messages: Y }, me = "identityDataType", ne = "guid", he = "Timestamp with time zone", de = "Timestamp with local time zone", j = function() {
const u = {
apex: { label: "APEX", value: "no", check: ["yes", "no"] },
auditcols: { label: "Audit Columns", value: "no", check: ["yes", "no"] },
Expand Down Expand Up @@ -9336,38 +9340,38 @@ const Y = {
`, v += `
*/`, this.ddl = v, v;
}, this.getErrors = function() {
return this.errors != null ? this.errors : (this.errors = Be.findErrors(this, this.fullInput), this.errors);
return this.errors != null ? this.errors : (this.errors = Pe.findErrors(this, this.fullInput), this.errors);
}, this.version = oe;
}
return D;
}();
function Pe(u, m) {
return Ae(u, m);
}
function ke(u, m) {
return new j(u, m).getERD();
return ye(u, m);
}
function Ee(u, m) {
return new j(u, m).getDDL();
return new j(u, m).getERD();
}
function Le(u, m) {
return new j(u, m).getDDL();
}
function Ne(u, m) {
return new j(u, m).getErrors();
}
function oe() {
return "1.2.12";
}
j.version = oe;
j.toDDL = Ee;
j.toERD = ke;
j.toErrors = Le;
j.fromJSON = Pe;
j.toDDL = Le;
j.toERD = Ee;
j.toErrors = Ne;
j.fromJSON = ke;
j.lexer = Q;
export {
j as default,
Pe as fromJSON,
ke as fromJSON,
oe as qsql_version,
j as quicksql,
Ee as toDDL,
ke as toERD,
Le as toErrors
Le as toDDL,
Ee as toERD,
Ne as toErrors
};
16 changes: 8 additions & 8 deletions dist/quick-sql.umd.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion doc/user/quick-sql-grammar.md
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ setting to override this default.
**Possible Values**: `11g`, `12c`, `19c`, `21c`, `23c`
**Default Value**: `19c`

Specifies the database version the syntax should be compatible with.
Specifies the database version the syntax should be compatible with. Only version number is significant (and not the postfix). Therefore, 21 and 23.1.1 are also legitimate values.

### drop

Expand Down
6 changes: 6 additions & 0 deletions src/naming.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,5 +116,11 @@ export function concatNames(chunk1, chunk2, chunk3) {
return ret;
}

export function getNumericVersion( pVersionString ) {
let lMatch = pVersionString.match( /^([0-9]+(?:[.][0-9]+)?)/ );
if ( !lMatch ) return null;
return lMatch[0];
}


export default {singular, canonicalObjectName, concatNames};
4 changes: 2 additions & 2 deletions src/tree.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {singular,concatNames,canonicalObjectName} from './naming.js';
import {singular,concatNames,canonicalObjectName, getNumericVersion} from './naming.js';
import translate from './translate.js';
import {generateSample, resetSeed} from './sample.js';
import lexer from './lexer.js';
Expand Down Expand Up @@ -340,7 +340,7 @@ let tree = (function(){
}
const dbVer = ddl.getOptionValue('db');
if( booleanCheck != '' && ( ddl.getOptionValue('boolean')=='native'
|| ddl.getOptionValue('boolean') != 'yn' && 0 < dbVer.length && dbVer.charAt(0) == '2' && dbVer.charAt(1) == '3' )
|| ddl.getOptionValue('boolean') != 'yn' && 0 < dbVer.length && 23 <= getNumericVersion(dbVer) )
) {
booleanCheck = '';
ret = 'boolean';
Expand Down
24 changes: 24 additions & 0 deletions test/small_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,19 @@ students

assert( "0 < output.indexOf('number default on null to_number(sys_guid()')" );

// https://github.com/oracle/quicksql/issues/51
output = new quicksql(`boolvalues
is_legal
finished_yn
ok bool
yes boolean
#db:"23"`).getDDL();

assert( "0 < output.indexOf('is_legal boolean,')" );
assert( "0 < output.indexOf('finished_yn boolean,')" );
assert( "0 < output.indexOf('ok boolean,')" );
assert( "0 < output.indexOf('yes boolean')" );

// https://github.com/oracle/quicksql/issues/51
output = new quicksql(`boolvalues
is_legal
Expand All @@ -645,7 +658,18 @@ students
assert( "0 < output.indexOf('finished_yn boolean,')" );
assert( "0 < output.indexOf('ok boolean,')" );
assert( "0 < output.indexOf('yes boolean')" );
// https://github.com/oracle/quicksql/issues/51
output = new quicksql(`boolvalues
is_legal
finished_yn
ok bool
yes boolean
#db:"23.1.1"`).getDDL();

assert( "0 < output.indexOf('is_legal boolean,')" );
assert( "0 < output.indexOf('finished_yn boolean,')" );
assert( "0 < output.indexOf('ok boolean,')" );
assert( "0 < output.indexOf('yes boolean')" );
// https://github.com/oracle/quicksql/issues/51
output = new quicksql(`boolvalues
ok bool
Expand Down