Skip to content

Commit 8f471ac

Browse files
+++
1 parent 2211861 commit 8f471ac

File tree

13 files changed

+267
-274
lines changed

13 files changed

+267
-274
lines changed

.github/workflows/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ The former calls `toDDL` and `toERD`
1818
are encouraged to be replaced with
1919

2020
```
21-
let parsed = new ddl(input,opt);
21+
let parsed = new parsed(input,opt);
2222
let output = parsed.getDDL();
2323
let errors = parsed.getErrors();
2424
```

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ See below for examples of how to use this library.
5151
### DDL NodeJS ECMA Script Module (ESM) Example
5252

5353
```js
54-
import { ddl } from "@oracle/quicksql";
54+
import { parsed } from "@oracle/quicksql";
5555
import fs from "fs";
5656

5757
try {
5858
const text = fs.readFileSync( './test/department_employees.quicksql' );
59-
console.log( new ddl( text.toString() ).getDDL() );
59+
console.log( new parsed( text.toString() ).getDDL() );
6060
} catch( e ) {
6161
console.error( e );
6262
};
@@ -65,12 +65,12 @@ try {
6565
### DDL NodeJS Common JS (CJS) Example
6666

6767
```js
68-
const { ddl } = require( "@oracle/quicksql" );
68+
const { parsed } = require( "@oracle/quicksql" );
6969
const fs = require( "fs" );
7070

7171
try {
7272
const text = fs.readFileSync( './test/department_employees.quicksql' );
73-
console.log( new ddl( text.toString() ).getDDL() );
73+
console.log( new parsed( text.toString() ).getDDL() );
7474
} catch( e ) {
7575
console.error( e );
7676
};
@@ -80,8 +80,8 @@ try {
8080

8181
```html
8282
<script type="module">
83-
import { ddl } from './dist/quick-sql.js';
84-
document.body.innerText = new ddl(
83+
import { parsed } from './dist/quick-sql.js';
84+
document.body.innerText = new parsed(
8585
`departments /insert 2
8686
name /nn
8787
location
@@ -107,7 +107,7 @@ view emp_v departments employees
107107
```html
108108
<script src="./dist/quick-sql.umd.cjs"></script>
109109
<script>
110-
document.body.innerText = new quickSQL.ddl(
110+
document.body.innerText = new quickSQL.parsed(
111111
`departments /insert 2
112112
name /nn
113113
location

dist/quick-sql.js

Lines changed: 148 additions & 148 deletions
Large diffs are not rendered by default.

dist/quick-sql.umd.cjs

Lines changed: 36 additions & 36 deletions
Large diffs are not rendered by default.

doc/user/error-diagnostics.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
Error diagnostics procedure is called like this
1717

1818
```js
19-
let output = ddl.errorMsgs(`dept
19+
let output = new parsed.(`dept
2020
col1
21-
"is this table or misaligned column?"`);
21+
"is this table or misaligned column?"`).getErrors();
2222
```
2323

2424
It returns an array of the Error objects

src/ddl.js

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const guid = 'guid';
1111
export const tswtz = 'Timestamp with time zone';
1212
export const tswltz = 'Timestamp with local time zone';
1313

14-
export const ddl = (function () {
14+
export const parsed = (function () {
1515

1616
const defaultOptions = {
1717
apex: {label: 'APEX', value:'no',check:['yes','no']},
@@ -471,8 +471,7 @@ export function toQSQL( input ) {
471471
* @returns JSON object listing tables and links
472472
*/
473473
export function toERD( input, options ) {
474-
const parsed = new ddl(input, options);
475-
return parsed.getERD();
474+
return new parsed(input, options).getERD();
476475
};
477476

478477
/**
@@ -482,8 +481,7 @@ export function toERD( input, options ) {
482481
* @returns translated DDL
483482
*/
484483
export function toDDL( input, options ) {
485-
const parsed = new ddl(input, options);
486-
return parsed.getDDL();
484+
return new parsed(input, options).getDDL();
487485
};
488486
/**
489487
* @deprecated since version 1.2.0.
@@ -492,17 +490,16 @@ export function toDDL( input, options ) {
492490
* @returns list of SyntaxError objects
493491
*/
494492
export function errors( input, options ) {
495-
const parsed = new ddl(input, options);
496-
return parsed.getErrors();
493+
return new parsed(input, options).getErrors();
497494
};
498495

499496
export const version = {
500497
writable: false,
501498
value: typeof __PACKAGE_VERSION__ === 'undefined' ? 'development' : __PACKAGE_VERSION__
502499
};
503500

504-
ddl.version = version;
505-
ddl.toDDL = toDDL; // legacy, deprecated
506-
ddl.toERD = toERD; // legacy, deprecated
501+
parsed.version = version;
502+
parsed.toDDL = toDDL; // legacy, deprecated
503+
parsed.toERD = toERD; // legacy, deprecated
507504

508-
export default ddl;
505+
export default parsed;

src/json2qsql.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {singular} from './naming.js';
2-
import {ddl} from "../src/ddl.js";
3-
2+
import {version} from './ddl.js';
43

54
var json2qsql = (function () {
65
function JSON2QSQL() {
@@ -102,7 +101,7 @@ var json2qsql = (function () {
102101
output += "\n\ndv "+key+"_dv "+key +"";
103102
output += '\n\n#settings = { genpk: false, drop: true }';
104103

105-
output += '\n\n-- Generated by json2qsql.js ' + `${ ddl.version } ` + new Date().toLocaleString() +'\n\n';
104+
output += '\n\n-- Generated by json2qsql.js ' + `${ version.value } ` + new Date().toLocaleString() +'\n\n';
106105

107106
output += '#document = \n';
108107
output += JSON.stringify(value, null, 3);

src/naming.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
export function singular( name ) {
2-
// ddl.options["Duality View"].value != 'yes'
32
// identity columns in JSON document are singular
43
if( name == null )
54
return name;

test/diagram_tests.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {ddl, toERD} from "../src/ddl.js";
1+
import {parsed, toERD} from "../src/ddl.js";
22

33
import fs from "fs";
44

@@ -44,10 +44,8 @@ export default function diagram_tests() {
4444
`Bug35827754
4545
data file
4646
`
47-
output = new ddl(input).getERD();
47+
output = new parsed(input).getERD();
4848

49-
//console.log(ddl.toDDL(input));
50-
//console.log(JSON.stringify(output, null, 4));
5149
assert( "output.items[0].columns[2].name == 'data_filename'" );
5250
assert( "output.items[0].columns[2].datatype == 'varchar2(255 char)'" );
5351
assert( "output.items[0].columns[5].name == 'data_lastupd'" );

test/error_msg_tests.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {errors, ddl} from "../src/ddl.js";
1+
import {errors, parsed} from "../src/ddl.js";
22
import errorMsgs from '../src/errorMsgs.js'
33

44

@@ -27,36 +27,36 @@ export default function error_msg_tests() {
2727
`);
2828
checkError(output, 1, 4, errorMsgs.messages.duplicateId);
2929

30-
output = new ddl(`dept
30+
output = new parsed(`dept
3131
name vc-200
3232
name vc0
3333
`).getErrors();
3434
checkError(output, 1, 4+4+2+1, errorMsgs.messages.invalidDatatype);
3535
checkError(output, 2, 4+4+1, errorMsgs.messages.invalidDatatype);
3636
checkNoError(output, errorMsgs.messages.misalignedAttribute);
3737

38-
output = new ddl(`dept
38+
output = new parsed(`dept
3939
name
4040
customer
4141
dept /fk department
4242
`).getErrors();
4343
checkError(output, 3, 4+4+1+3+1, errorMsgs.messages.undefinedObject+'department');
4444
checkNoError(output, errorMsgs.messages.misalignedAttribute);
4545

46-
output = new ddl(`dept
46+
output = new parsed(`dept
4747
name
4848
view customer_view customer
4949
`).getErrors();
5050
checkError(output, 2, 4+1+13+1, errorMsgs.messages.undefinedObject+'customer');
5151
checkNoError(output, errorMsgs.messages.misalignedAttribute);
5252

53-
output = new ddl(`dept
53+
output = new parsed(`dept
5454
col1
5555
"is this table or misaligned column?"
5656
`).getErrors();
5757
checkError(output, 2, 4, errorMsgs.messages.misalignedAttribute+"3");
5858

59-
output = new ddl(`dept
59+
output = new parsed(`dept
6060
col1
6161
col2
6262
"is this table or misaligned column?"

0 commit comments

Comments
 (0)