Skip to content
This repository has been archived by the owner on Oct 6, 2019. It is now read-only.

Commit

Permalink
Fixed import/export bug
Browse files Browse the repository at this point in the history
Which was there due to table and columns were not quoted. Also removed
regex matching for columns during import, since we now support
“everything” - According to MySQL’s dox at least …
  • Loading branch information
Thomas Hansen committed Sep 26, 2017
1 parent f8609e7 commit b25c5d9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 22 deletions.
4 changes: 2 additions & 2 deletions template/helpers/export-items.hl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ for-each:x:/@load-file/*/*/field
* Adding column to SQL.
*/
set:x:/@_cols?value
src:{0},{1}
src:{0},`{1}`
:x:/@_cols?value
:x:/@_dp/#/*/name?value

Expand All @@ -64,7 +64,7 @@ p5.mysql.connect:[camphora]
/*
* Runninq query.
*/
p5.mysql.select:@"select {0} from {1}"
p5.mysql.select:@"select {0} from `{1}`"
:x:/@_cols?value
:x:/../*/app-name?value

Expand Down
28 changes: 9 additions & 19 deletions template/helpers/upload-file.hl
Original file line number Diff line number Diff line change
Expand Up @@ -37,36 +37,26 @@ load-file:{0}{1}{2}
_cols
_pars
.cols
_no:int:0
for-each:x:/@load-file/*/*/[0,1]/*?name

/*
* Sanity checking column name, to avoid SQL injection attacks.
*/
match:x:/@_dp?value
src:regex:"/^[_a-z]{3,}$/i"
if:x:/@match/*?count
=:int:0
or:x:/@match/0?name
=:

/*
* Malformed column name in CSV file.
*/
throw:Malformed column name in CSV file.

/*
* Adding column to SQL.
*/
set:x:/@_cols?value
src:{0},{1}
src:{0},`{1}`
:x:/@_cols?value
:x:/@_dp?value
set:x:/@_pars?value
src:{0},@{1}
:x:/@_pars?value
:x:/@_dp?value
:x:/@_no?value
add:x:/@.cols
src:x:/@_dp?value
src:@{0}
:x:/@_no?value
set:x:/@_no?value
+:x:/@_no?value
_:1



Expand Down Expand Up @@ -125,7 +115,7 @@ p5.mysql.connect:[camphora]
/*
* Doing actual insertion of items.
*/
p5.mysql.insert:@"insert into {0} ({1}) values ({2})"
p5.mysql.insert:@"insert into `{0}` ({1}) values ({2})"
:x:/../*/app-name?value
:x:/@_cols?value
:x:/@_pars?value
Expand Down
2 changes: 1 addition & 1 deletion template/launch.hl
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ window.onscroll = function() {
* Deleting all records from database.
*/
p5.mysql.connect:[camphora]
p5.mysql.delete:@"delete from {0}"
p5.mysql.delete:@"delete from `{0}`"
:x:/@_app-name?value

/*
Expand Down

0 comments on commit b25c5d9

Please sign in to comment.