Skip to content
This repository was archived by the owner on Jul 15, 2021. It is now read-only.

Commit f2adb07

Browse files
committed
new specs for CREATE TRIGGER and datatypes. refs #2
1 parent 9a141da commit f2adb07

File tree

11 files changed

+340
-163
lines changed

11 files changed

+340
-163
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
All notable changes to this project will be documented in this file.
33

44
## [Unreleased][unreleased]
5+
### Added
6+
- new specs for `CREATE TRIGGER` and datatypes
7+
58
### Changed
69
- added a bunch of missing descriptions for grammar rules in `grammar.pegjs`
710
- make sure that a `description` is not repeated in smart error message

demo/sqlite-parser-demo.js

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

dist/sqlite-parser.js

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

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
}
2020
}
2121
sqliteParser['NAME'] = 'sqlite-parser';
22-
sqliteParser['VERSION'] = '0.9.2';
22+
sqliteParser['VERSION'] = '0.9.3';
2323

2424
module.exports = root.sqliteParser = sqliteParser;
2525
})(typeof self === 'object' ? self : global);

lib/parser.js

Lines changed: 83 additions & 50 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "sqlite-parser",
33
"description": "JavaScript implentation of SQLite 3 query parser",
44
"author": "Code School (http://codeschool.com)",
5-
"version": "0.9.2",
5+
"version": "0.9.3",
66
"contributors": [
77
"Nick Wronski <nick@javascript.com>"
88
],

src/grammar.pegjs

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1349,7 +1349,7 @@ create_table "CREATE TABLE Statement"
13491349
}
13501350

13511351
create_core_tmp
1352-
= t:( TEMP / TEMPORARY ) e
1352+
= t:( TEMPORARY / TEMP ) e
13531353
{ return util.key(t); }
13541354

13551355
create_core_ine "IF NOT EXISTS Modifier"
@@ -1978,14 +1978,28 @@ operator_unary "Unary Operator"
19781978

19791979
/* TODO: Needs return format refactoring */
19801980
operator_binary "Binary Operator"
1981-
= o:( binary_concat / expression_isnt
1982-
/ binary_multiply / binary_mod
1983-
/ binary_plus / binary_minus
1984-
/ binary_left / binary_right / binary_and / binary_or
1985-
/ binary_lte / binary_lt / binary_gte / binary_gt
1986-
/ binary_lang / binary_notequal / binary_equal )
1981+
= o:( binary_nodes )
19871982
{ return util.key(o); }
19881983

1984+
binary_nodes
1985+
= binary_concat
1986+
/ expression_isnt
1987+
/ binary_multiply
1988+
/ binary_mod
1989+
/ binary_plus
1990+
/ binary_minus
1991+
/ binary_left
1992+
/ binary_right
1993+
/ binary_and
1994+
/ binary_or
1995+
/ binary_lte
1996+
/ binary_lt
1997+
/ binary_gte
1998+
/ binary_gt
1999+
/ binary_lang
2000+
/ binary_notequal
2001+
/ binary_equal
2002+
19892003
binary_concat "Or"
19902004
= sym_pipe sym_pipe
19912005

test/index-spec.js

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/sql/basicCreateTrigger.sql

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ CREATE TRIGGER cust_addr_chng
22
INSTEAD OF UPDATE OF cust_addr ON customer_address
33
WHEN cust_addr NOT NULL
44
BEGIN
5-
UPDATE customer SET cust_addr=NEW.cust_addr
6-
WHERE cust_id=NEW.cust_id;
5+
UPDATE customer
6+
SET cust_addr=NEW.cust_addr
7+
WHERE cust_id=NEW.cust_id;
78
END;

test/sql/basicCreateTrigger2.sql

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CREATE TEMPORARY TRIGGER IF NOT EXISTS happy_bee_time
2+
BEFORE DELETE ON bees
3+
FOR EACH ROW
4+
WHEN name == 'Nick'
5+
BEGIN
6+
INSERT INTO hive (id, name) VALUES
7+
(4, 'A Better Hive');
8+
INSERT INTO bees (name, color, hive_id) VALUES
9+
('New Nick', 'purple', 4);
10+
END;

0 commit comments

Comments
 (0)