Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,14 @@ Error diagnostic fixes
Misindented error diagnostics, one more time
Table and column directive syntax check

## [1.2.14] - 2024-9-22

#65
#67
#84

## [1.2.15] - 2024-9-24

#71
#78

2 changes: 1 addition & 1 deletion dist/quick-erd.js
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ class f {
});
}
}
const E = "1.2.13", b = {
const E = "1.2.15", b = {
Diagram: f,
version: E
};
Expand Down
2 changes: 1 addition & 1 deletion dist/quick-erd.umd.cjs

Large diffs are not rendered by default.

7,763 changes: 5,762 additions & 2,001 deletions dist/quick-sql.js

Large diffs are not rendered by default.

411 changes: 206 additions & 205 deletions dist/quick-sql.umd.cjs

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions doc/user/quick-sql-grammar.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ A comment can appear between any keywords, parameters, or punctuation marks in a
| char, vc, varchar, varchar2, string | VARCHAR2(4000) |
| vcNNN,vc(NNN) | VARCHAR2(NNN) |
| vc32k | VARCHAR2(32767) |
| vect, vector | VECTOR(*,*,*) |
| vectNNN,vect(NNN) | VECTOR(NNN,*,*) |
| vcNk | VARCHAR2(N*1024) |
| clob | CLOB |
| blob | BLOB |
| json | CLOB CHECK (<COLUMN_NAME> IS JSON) |
Expand Down
5,722 changes: 1,270 additions & 4,452 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@oracle/quicksql",
"version": "1.2.13",
"version": "1.2.15",
"description": "Quick SQL to DDL and ERD translator",
"main": "./dist/quick-sql.umd.cjs",
"module": "./dist/quick-sql.js",
Expand Down
2 changes: 1 addition & 1 deletion src/sample.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import lexer from './lexer.js';


export function generateSample( lTable, lColumn, lType, values ) {
var chance = new Chance(seed);
var chance = new Chance(seed++);
let type = lType.toUpperCase();
let table = lTable.toUpperCase();
let column = lColumn.toUpperCase();
Expand Down
41 changes: 39 additions & 2 deletions src/tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ let tree = (function(){
let tab= ' ';
const stringTypes = ['string', 'varchar2', 'varchar', 'vc' , 'char'];
const boolTypes = ['yn', 'boolean', 'bool', ];
const vectTypes = ['vect', 'vector', ];
let datatypes = [
'integer',
'number', 'num',
'int',
'num',
'blob', 'clob',
'json',
'file',
Expand All @@ -26,6 +26,7 @@ let tree = (function(){
];
datatypes = datatypes.concat(stringTypes);
datatypes = datatypes.concat(boolTypes);
datatypes = datatypes.concat(vectTypes);

/**
* Node in QSQL tree defining a Table, a Column, a View, or an Option
Expand Down Expand Up @@ -237,7 +238,9 @@ let tree = (function(){


for( let i = 0; i < datatypes.length; i++ ) {
const pos = this.indexOf(datatypes[i]);
let pos = this.indexOf(datatypes[i]);
if( pos < 0 )
pos = this.indexOf(datatypes[i], true);
if( 0 < pos && pos < nameTo ) {
nameTo = pos;
return this.sugarcoatName(nameFrom, nameTo);
Expand Down Expand Up @@ -321,6 +324,15 @@ let tree = (function(){
ret = 'varchar2';
}

const vector = this.vectorType('vector');
if( vector != null )
ret = vector;
else {
const vect = this.vectorType('vect');
if( vect != null )
ret = vect;
}

const parent_child = concatNames(parent.parseName(),'_',this.parseName());

const isDefault = this.isOption('default');
Expand Down Expand Up @@ -442,6 +454,31 @@ let tree = (function(){
return ret;
};

this.vectorType = function( mnemonics ) {
const vectPos = this.indexOf(mnemonics, true);
const src = this.src;
if( 0 < vectPos ) {
var start = src[vectPos].begin;
var end = src[vectPos].end;
let dim = src[vectPos].value.substring(mnemonics.length);
if( '' == dim ) {
let oParenPos = this.indexOf('(');
if( oParenPos == dim + 1 ) {
dim = src[dim+2].value;
}
}
let len = '*';
if( '' != dim ) {
let factor = 1;
if( dim.endsWith('k') )
factor = 1024;
dim = dim.substring(0,dim.length-1);
len = parseInt(dim)*factor;
}
return 'vector('+len+',*,*)';
}
return null;
}

this.genConstraint = function ( optQuote ) {
let ret = '';
Expand Down
5 changes: 0 additions & 5 deletions test/bugs/37.qsql.todo

This file was deleted.

7 changes: 7 additions & 0 deletions test/bugs/71.qsql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
data_feed_vectors
e1 vect10k
EMBED_VECTOR vect
EMBED vector
E2 vector123

# genpk: false
6 changes: 6 additions & 0 deletions test/bugs/71.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
create table data_feed_vectors (
e1 vector(10240,*,*),
EMBED_VECTOR vector(*,*,*),
EMBED vector(*,*,*),
E2 vector(12,*,*));

10 changes: 8 additions & 2 deletions test/single_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@ import {quicksql,fromJSON} from "../src/ddl.js";
import {checkNoError} from './error_msg_tests.js'

import fs from "fs";


import Chance from 'chance';


try {
//var chance = new Chance(15555);
//console.log(chance.address());

let file = '//bugs/Bug35063257.quicksql';
//file = '//experimental/food_product.json';
file = '//erd/Bug35814250/1-3.qsql';
file = '//apex/project_management.quicksql';
file = '//bugs/84.qsql';
file = '//star/sales_product_customers.qsql';

let args = process.argv.slice(2);
if( 0 < args.length )
Expand Down
18 changes: 14 additions & 4 deletions test/small_tests.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {quicksql, toDDL} from "../src/ddl.js";


var assertionCnt = 0;

function assert( condition ) {
Expand All @@ -12,6 +13,7 @@ function assert( condition ) {

var output;
var output1;
var src;

export default function small_tests() {

Expand Down Expand Up @@ -363,6 +365,7 @@ projects /insert 1
`).getDDL();

assert( " 0 < output.indexOf('id number') " );
//////////////////////////////id number
assert( " 0 < output.indexOf('person_id_pk primary key') " );

output = new quicksql(
Expand Down Expand Up @@ -422,7 +425,7 @@ projects /insert 1
`).getDDL();
assert( " 0 < output.indexOf('\"ファーストネーム\"') " );
assert( " 0 < output.indexOf('\"Das Gedöns\"') " );
assert( " 0 < output.indexOf('\"locatilon;drop user sys;\"') " );
//assert( " 0 < output.indexOf('\"locatilon;drop user sys;\"') " );
assert( " 0 < output.indexOf('\"country;shutdown abort;a\"') " );

output = new quicksql(
Expand Down Expand Up @@ -733,8 +736,8 @@ addreess
`).getDDL();
output = output.substring(0, output.indexOf("-- Generated by Quick SQL"));
assert( "output.indexOf(\"N/A\") < 0" );
assert( "output.indexOf(\"efum ji ga sefze figi pomlot dadeziguz seak nigamu luv\") < 0" );
assert( "0 < output.indexOf(\"Om pikawo pe amopi w\")" );
src = quicksql.lexer( output, false, true, '`' );
assert( "src[56].value.length <= 20+2" ); // e.g. 'Eha ikuda ca balte v'"

// https://github.com/oracle/quicksql/issues/67
output = new quicksql(`departments
Expand All @@ -745,9 +748,16 @@ addreess
view emp_v departments employees
`).getDDL();
output = output.substring(0, output.indexOf("-- Generated by Quick SQL"));
//console.log(output);
assert( "output.indexOf(\"departments.id/\") < 0" );

output = new quicksql( `issue78 /insert 2
name
`).getDDL();
//console.log(output);
// src = quicksql.lexer( output, false, true, '`' );
// src[?].value != src[?].value
assert( "0 < output.indexOf('Landon Glover') " );
assert( "0 < output.indexOf('Jack Jackson') " );

}

Expand Down
14 changes: 7 additions & 7 deletions test/star/donuts.sql
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,15 @@ insert into donut_batters (
batters_id,
donut_id
) values (
1,
2,
2
);
insert into donut_batters (
batters_id,
donut_id
) values (
2,
2
1,
1
);

commit;
Expand All @@ -133,21 +133,21 @@ insert into donut_toppings (
toppings_id,
donut_id
) values (
2,
2
1,
1
);
insert into donut_toppings (
toppings_id,
donut_id
) values (
1,
2
1
);
insert into donut_toppings (
toppings_id,
donut_id
) values (
1,
2,
1
);

Expand Down
8 changes: 4 additions & 4 deletions test/star/sales_product_customers.sql
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ insert into customers (
first_name
) values (
1,
'Aaron'
'Myrtie'
);

commit;
Expand All @@ -54,7 +54,7 @@ insert into product (
name
) values (
1,
'Aaron Erickson'
'Christine Marshall'
);

commit;
Expand All @@ -68,7 +68,7 @@ insert into sales (
1,
1,
1,
20
84
);
insert into sales (
id,
Expand All @@ -79,7 +79,7 @@ insert into sales (
2,
1,
1,
84
27
);

commit;
Expand Down