Skip to content

Commit 402027b

Browse files
issue 55 (almost complete)
1 parent 5c2ed80 commit 402027b

File tree

7 files changed

+2106
-1981
lines changed

7 files changed

+2106
-1981
lines changed

dist/quick-sql.js

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

dist/quick-sql.umd.cjs

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

src/lexer.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,15 @@ var lexer = (function(){
1111
this.toString = function() {
1212
return '{type:'+type+',value:'+value+'}';
1313
};
14+
this.getValue = function() {
15+
if( this.value == null || this.value.length < 2 )
16+
return this.value;
17+
if( this.value.charAt(0) == '`' ) {
18+
let ret = this.value.substring(1,this.value.length-1);
19+
ret = "q'[" + ret + "]'";
20+
}
21+
return this.value;
22+
};
1423
this.isStandardLiteral = function () {
1524
// fast fail
1625
if( this.value.length < 2 )

src/sample.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,20 @@ export function generateSample( lTable, lColumn, lType, values ) {
1111
if( values != null && 0 < values.length ) {
1212
let min = 0;
1313
let max = values.length;
14+
let value = values[Math.floor(seededRandom() * (max - min)) + min];
1415
var optQuote = '\'';
1516
if( type.startsWith('INTEGER') || type.startsWith('NUMBER') || type.startsWith('DATE') )
1617
optQuote = '';
17-
let value = values[Math.floor(seededRandom() * (max - min)) + min];
18-
if( value.toLowerCase && value.toLowerCase() == 'null' )
19-
optQuote = '';
20-
if( value.replaceAll )
21-
value = value.replaceAll('\'','\'\'');
18+
else {
19+
if( value.toLowerCase && value.toLowerCase() == 'null' )
20+
optQuote = '';
21+
if( value.charAt && value.charAt(0) == '\'' )
22+
optQuote = '';
23+
if( value.charAt && value.charAt(0) == 'q' && value.charAt(1) == '\'' )
24+
optQuote = '';
25+
}
26+
if( value.replaceAll && 0 < value.indexOf('\'') && value.indexOf('\'') < value.length-1 )
27+
value = value.replaceAll('\'','\'\'');
2228
return optQuote+value+optQuote;
2329
}
2430

0 commit comments

Comments
 (0)