Commit graph

272 commits

Author SHA1 Message Date
Tobie Morgan Hitchcock
a569ad78d6 Improve statement read/write status detection
Only store read-write statement status in the database for statements which can be either read or write. For those statements which are always write statements (Live, Kill, Create, Update, Delete, Relate, Insert, Upsert, Define, Remove….), then hardcode this on the statement itself.
2017-11-24 12:56:53 +00:00
Tobie Morgan Hitchcock
8de7424efb Ensure the IfStatement can be encoded and decoded into cork 2017-11-24 12:47:59 +00:00
Tobie Morgan Hitchcock
1d08949fff Full update of the SQL package 2017-11-16 20:53:13 +00:00
Tobie Morgan Hitchcock
4c16dafcf3 Add duration method to killable statements 2017-04-28 17:12:11 +01:00
Tobie Morgan Hitchcock
b60c663fdd SQL models need a different min and max value
If the same minimum and maximum value is used in a SQL model … |person:1..1| then the sql query parser will fail.
2017-04-28 17:09:35 +01:00
Tobie Morgan Hitchcock
dacf7b954b Enable WITH aswell as TO in RELATE clause 2017-04-28 17:07:38 +01:00
Tobie Morgan Hitchcock
8a53ed3617 Fix SQL tests 2017-04-14 13:24:53 +01:00
Tobie Morgan Hitchcock
7aca98a581 No need to generate codec code definitions
SQL ASTs are never outputted to the end user, but instead are only ever encoded/decoded using CORK, so we don’t need to pre-generate any code definitions for codec (JSON, BINC, CBOR, MsgPack).
2017-04-14 13:22:29 +01:00
Tobie Morgan Hitchcock
aa7e4ac561 Enable model expressions in SQL parser
The SQL parser now supports model expressions for defining ranges using the |table:0,0.5..100| notation syntax.
2017-04-14 13:21:08 +01:00
Tobie Morgan Hitchcock
2de5a8fa3f Simplify parsing @table:thing definitions 2017-04-14 13:13:31 +01:00
Tobie Morgan Hitchcock
a3da779190 Improve SQL error messages 2017-04-12 18:45:52 +01:00
Tobie Morgan Hitchcock
9df4c5041a Use pointer 2017-04-12 18:44:01 +01:00
Tobie Morgan Hitchcock
17b1f9ff55 Fix JSON parsing in SQL
Previously, JSON which contained bracket `[]` or brace `{}` characters inside strings would fail to parse as valid JSON.
2017-04-12 17:44:27 +01:00
Tobie Morgan Hitchcock
5a558c0d6f Implement Authable statements for improved logging 2017-03-24 21:25:22 +00:00
Tobie Morgan Hitchcock
7a071af821 Download generate dependencies in each gen files 2017-03-04 10:55:58 +00:00
Tobie Morgan Hitchcock
a96a8466cb Add initial golang code tracing and logging 2017-03-03 21:39:37 +00:00
Tobie Morgan Hitchcock
98db89a2d7 Implement query statement timeout functionality 2017-03-02 14:38:56 +00:00
Tobie Morgan Hitchcock
378bbe6dae Ensure default tables/fields are private by default 2017-03-02 10:55:42 +00:00
Tobie Morgan Hitchcock
2d5151c8ba Enable SQL AST string formatting 2017-03-02 10:47:10 +00:00
Tobie Morgan Hitchcock
1157835a29 Don’t perform cpu intensive operations in SQL parser 2017-03-02 10:32:20 +00:00
Tobie Morgan Hitchcock
6e223f5f08 Move authentication level constants to cnf package
Instead of defining the authentication level types as ints in the sql package, there is now a specific type which is now located in the cnf package.
2017-02-24 13:33:03 +00:00
Tobie Morgan Hitchcock
e4bef0c4b7 Differentiate between IDENT and EXPR in SQL
Previously it was possible to CREATE/UPDATE/DELETE path expressions as this would satisfy an IDENT in the SQL parser.

Now however, there is a difference between an IDENT and an EXPR…

IDENT: person | person_main | person123
EXPR: person | person.path | person[0].path

As a result, path expressions are only possible when setting data or setting conditional conditions.
2017-02-24 13:05:07 +00:00
Tobie Morgan Hitchcock
d27e00e737 Fix sql tests 2017-02-23 15:09:02 +00:00
Tobie Morgan Hitchcock
e10debba6c Enable query params for USE NS / USE DB in queries 2017-02-20 01:44:13 +00:00
Tobie Morgan Hitchcock
ac868694eb Enable query params for VERSION in queries 2017-02-20 01:44:13 +00:00
Tobie Morgan Hitchcock
6a719d815b Improve errors throught codebase 2017-02-20 01:44:13 +00:00
Tobie Morgan Hitchcock
cd7922db15 Enable query params for LIMIT and START in queries 2017-02-20 01:44:12 +00:00
Tobie Morgan Hitchcock
83a64c6c29 Enforce default RETURN value in sql parser 2017-02-20 01:44:12 +00:00
Tobie Morgan Hitchcock
3ffaec9265 Remove RETURN statement from SELECT query 2017-02-20 01:44:12 +00:00
Tobie Morgan Hitchcock
3f82f83cf1 Remove SQL error for embedded DEFINE/REMOVE queries 2017-02-20 01:44:12 +00:00
Tobie Morgan Hitchcock
b62b7ed2c9 Don’t use pointer as we already are a pointer 2017-02-20 01:44:11 +00:00
Tobie Morgan Hitchcock
6c82529d85 JSON Patch expects only array in SQL, not object 2017-02-20 01:44:11 +00:00
Tobie Morgan Hitchcock
b724d864f8 Add ability to define NAMESPACE without DATABASE
Once somebody had specified USE NAMESPACE to select a namespace, it was not possible to DEFINE a DATABASE underneath the NAMESPACE, as an error that ‘no database is selected’ would be returned. Not it is possible to DEFINE DATABASE having selected only a NAMESPACE.
2017-02-20 01:44:11 +00:00
Tobie Morgan Hitchcock
7d88c389e1 Enable use of SQL DEFINE/REMOVE in transactions 2017-02-20 01:44:11 +00:00
Tobie Morgan Hitchcock
dd230dca56 Enable SQL ASTs to self-encode and self-decode 2017-02-20 01:44:11 +00:00
Tobie Morgan Hitchcock
1fd450890b Fix typo 2017-02-20 01:44:10 +00:00
Tobie Morgan Hitchcock
dfee11339e Fix SQL bug where NAMESPACE/DATABASE were needed twice
DEFINE NAMESPACE and REMOVE NAMESPACE statements expected two NAMESPACE keywords in the SQL query.

DEFINE DATABASE and REMOVE DATABASE statements expected two DATABASE keywords in the SQL query.
2017-02-09 10:31:53 +00:00
Tobie Morgan Hitchcock
74658132c1 Enable password field types 2017-02-03 19:10:51 +00:00
Tobie Morgan Hitchcock
1901f6fd8c Enable simplified json in SQL queries 2017-02-03 19:08:57 +00:00
Tobie Morgan Hitchcock
a941987349 Remove unnecessary return statement 2017-02-03 19:08:37 +00:00
Tobie Morgan Hitchcock
e3c472b31a Remove incorrect build tags 2017-01-11 11:22:17 +00:00
Tobie Morgan Hitchcock
fa40f52302 Place build instruction before package name 2016-12-08 22:04:22 +00:00
Tobie Morgan Hitchcock
9b8aec6549 Add SQL functions for hotp/totp/yubikey security 2016-12-08 21:57:22 +00:00
Tobie Morgan Hitchcock
fbe34c6083 Add PERMISSIONS and remove DEFINE / REMOVE RULES 2016-11-26 13:39:03 +00:00
Tobie Morgan Hitchcock
2b47e6e0a9 No need for a default TYPE on SQL DEFINE FIELD
Previously the default type for DEFINE FIELD statements was “any”, but this is unnecessary, as fields with type “any” are not type-checked anyway, so there is little point in defining the default as “any”. Therefore the type is left blank if no TYPE is specifically defined.
2016-11-26 13:35:58 +00:00
Tobie Morgan Hitchcock
90953735d9 DEFINE and REMOVE SQL queries can not be inside transactions 2016-11-26 13:05:21 +00:00
Tobie Morgan Hitchcock
2fcc2e3668 Improve SQL INFO command to support namespaces 2016-11-23 12:53:27 +00:00
Tobie Morgan Hitchcock
75b5f2f412 Improve SQL DEFINE TOKEN statements 2016-11-22 19:10:42 +00:00
Tobie Morgan Hitchcock
063de926ed Improve SQL DEFINE LOGIN statements 2016-11-22 19:10:32 +00:00
Tobie Morgan Hitchcock
f150e5b587 Increase bit length of SQL TOKEN keys 2016-11-22 19:09:02 +00:00
Tobie Morgan Hitchcock
8cdae77483 Generate token keys in SQL and store as binary 2016-11-22 13:51:21 +00:00
Tobie Morgan Hitchcock
bb752eb124 Encrypt SQL LOGIN password immediately 2016-11-22 13:36:57 +00:00
Tobie Morgan Hitchcock
5bfe938fcf Enable authentication tokens on SCOPES 2016-11-21 18:58:07 +00:00
Tobie Morgan Hitchcock
2783c4c653 Add authentication level checks to SQL INFO query 2016-11-21 18:52:51 +00:00
Tobie Morgan Hitchcock
b25ce6d059 If no TYPE is found on SQL DEFINE FIELD default to “any” 2016-11-21 18:52:12 +00:00
Tobie Morgan Hitchcock
94c9631d91 Improve database authentication
Improve the database authentication implementation for namespaces, databases, and scopes.
2016-11-21 18:48:25 +00:00
Tobie Morgan Hitchcock
19650ab770 Remove POLICY from SQL DEFINE SCOPE statement 2016-11-21 18:43:15 +00:00
Tobie Morgan Hitchcock
4e039cff44 Add basic sql functions for crypto 2016-11-21 14:34:15 +00:00
Tobie Morgan Hitchcock
0fa8537624 No need to have selected a NS/DB for transactions 2016-11-17 14:18:33 +00:00
Tobie Morgan Hitchcock
ee6653c289 Improve SQL DEFINE SCOPE statement 2016-11-16 22:47:43 +00:00
Tobie Morgan Hitchcock
cf79487b81 Add SQL DEFINE TOKEN statement 2016-11-16 22:47:23 +00:00
Tobie Morgan Hitchcock
a66c604c2f Add SQL DEFINE LOGIN statement 2016-11-16 22:46:57 +00:00
Tobie Morgan Hitchcock
2a10913b06 Change name of authentication scope level 2016-11-14 13:26:07 +00:00
Tobie Morgan Hitchcock
cd20e647a0 No need to check auth level when choosing NS/DB 2016-11-14 13:23:34 +00:00
Tobie Morgan Hitchcock
63e516b63f Add method for parsing json object directly 2016-11-14 13:22:43 +00:00
Tobie Morgan Hitchcock
cd44c77de6 Improve error message when unable to select NS/DB 2016-11-14 10:20:45 +00:00
Tobie Morgan Hitchcock
3038b6adec Rename file 2016-11-13 19:21:34 +00:00
Tobie Morgan Hitchcock
45b06dfd9b Remove unused SQL tokens 2016-11-10 12:36:01 +00:00
Tobie Morgan Hitchcock
4f04721b31 Enable times as basic LET variables and set immediately 2016-11-09 15:18:11 +00:00
Tobie Morgan Hitchcock
0292140d3c Enable NOW keyword as shortcut for now() in SQL 2016-11-09 15:16:09 +00:00
Tobie Morgan Hitchcock
b0f8ed6b56 Improving parsing of time durations.
Previously, the number 0 was parsed as 0ns.

In addition, it is now not possible to have duration values defined as strings (inside “” or ‘’).

However, now values are explicitly marked as a duration only if they have a valid DURATION suffix. Anlything else is either a NUMBER of an IDENT.
2016-11-09 15:15:09 +00:00
Tobie Morgan Hitchcock
fdbf38f833 Enable parameters in @thing:id in sql parser 2016-11-05 14:10:59 +00:00
Tobie Morgan Hitchcock
c53efdb06f Define basic parameters immediately 2016-11-05 14:00:15 +00:00
Tobie Morgan Hitchcock
77aa2adaf7 Update SQL tests 2016-11-04 12:15:51 +00:00
Tobie Morgan Hitchcock
3016dfae99 This should never have been here in the first place 2016-11-04 11:49:50 +00:00
Tobie Morgan Hitchcock
54ad8a16d9 Add codec code generation 2016-11-04 11:45:38 +00:00
Tobie Morgan Hitchcock
2e94c2fe02 Add AND UPSERT to UPDATE statement 2016-11-04 11:43:59 +00:00
Tobie Morgan Hitchcock
61e884c529 Add AND EXPUNGE to DELETE statement 2016-11-04 11:43:32 +00:00
Tobie Morgan Hitchcock
eb90f2a1b7 Update code comment 2016-11-04 11:34:48 +00:00
Tobie Morgan Hitchcock
b9327723f8 Add SQL command for DEFINE/REMOVE DATABASE 2016-11-04 11:34:37 +00:00
Tobie Morgan Hitchcock
15103e202b Add SQL command for DEFINE/REMOVE NAMESPACE 2016-11-04 11:33:57 +00:00
Tobie Morgan Hitchcock
b720213bd4 Perform authentication access checks in SQL layer 2016-11-04 11:25:53 +00:00
Tobie Morgan Hitchcock
defe873d7d Add back in field parsing expressions 2016-11-04 11:17:11 +00:00
Tobie Morgan Hitchcock
57f49576db Serialize and deserialize Tokens as strings 2016-11-04 11:16:41 +00:00
Tobie Morgan Hitchcock
b0ab86c4ef Add KV, NS, DB to LET and RETURN SQL ASTs
All queries which manipulate the data layer in any way, should at least store the authenticated/selected NS and DB options, even if they do not actually use them when running the SQL statement.
2016-11-04 11:15:05 +00:00
Tobie Morgan Hitchcock
d8a2d40d34 Update SQL tests 2016-11-04 11:13:34 +00:00
Tobie Morgan Hitchcock
b5c8b21eb6 Enable durations to be specified without “” marks 2016-11-04 10:04:55 +00:00
Tobie Morgan Hitchcock
4d9f9b297e Fix single line comment bug
Comments which were on the last line of an SQL query would cause the scanner to never reach the end of the reader stream, hangining indefinitely.

This fix ensures that the single line comment is ended when an EOF is reached.
2016-11-04 10:04:31 +00:00
Tobie Morgan Hitchcock
6e4a229a96 Add && + || as alternatives for AND + OR in SQL 2016-11-04 10:03:07 +00:00
Tobie Morgan Hitchcock
e0bcd5ff37 No need to create extra variable 2016-11-04 10:02:00 +00:00
Tobie Morgan Hitchcock
b5da299ea3 Add CORK self encoding to SQL objects 2016-11-04 10:01:32 +00:00
Tobie Morgan Hitchcock
68c22bc25c Add subqueries, subexpressions, and paths to SQL 2016-11-04 09:58:11 +00:00
Tobie Morgan Hitchcock
28d1806785 Simplify JSON expression parsing 2016-11-04 09:45:11 +00:00
Tobie Morgan Hitchcock
45be69637e Add ‘record’ as a field type 2016-11-04 09:42:00 +00:00
Tobie Morgan Hitchcock
1733f84070 Enable main SQL commands to be within subqueries 2016-11-03 17:20:18 +00:00
Tobie Morgan Hitchcock
dd21b8879a Only do function argument checking in sql parser 2016-11-03 17:16:08 +00:00
Tobie Morgan Hitchcock
3b20033ebf Update PATH token types
Remove unused PATH token and move EDGE tokens to literals.
2016-11-03 08:13:34 +00:00
Tobie Morgan Hitchcock
7e9c595ff7 Add blueprint for RELATE SQL query 2016-10-30 16:59:16 +00:00
Tobie Morgan Hitchcock
feea12f93d Remove unused and backup SQL keywords 2016-10-30 14:05:29 +00:00
Tobie Morgan Hitchcock
151d73b954 Remove MODIFY SQL command and add DIFF to UPDATE
MODIFY SQL statements have now been merged with UPDATE SQL statements, as the functionality was similar, but the code was duplicated.

The DIFF SQL command has been added to the UPDATE query, so that records can be updated with DIFFs.
2016-10-30 00:33:28 +01:00
Tobie Morgan Hitchcock
872f4abf43 Update SQL package tests 2016-10-29 18:47:09 +01:00
Tobie Morgan Hitchcock
d4491d557b Support JSON and ARRAYS in RETURN statements 2016-10-29 18:46:48 +01:00
Tobie Morgan Hitchcock
c08e9d69c9 Use actual @things not strings for item ids 2016-10-29 12:44:49 +01:00
Tobie Morgan Hitchcock
6077dc2952 Add SQL RETURN statements 2016-10-29 12:29:20 +01:00
Tobie Morgan Hitchcock
174cc8bcad Add SQL LET statements with bound parameters 2016-10-29 12:28:20 +01:00
Tobie Morgan Hitchcock
cc74e7a67e Use interface type for @thing TB 2016-10-29 11:38:52 +01:00
Tobie Morgan Hitchcock
abf9c937be Ensure @thing:id is int64 if whole number 2016-10-29 10:20:10 +01:00
Tobie Morgan Hitchcock
4951aa61f6 Enable double slash single line comments 2016-10-24 12:11:12 +01:00
Tobie Morgan Hitchcock
4c8d5213dc Add double FIELD TYPE and improve type checking 2016-10-20 14:14:10 +01:00
Tobie Morgan Hitchcock
2290a95ec6 Add SQL SCOPE query type 2016-10-18 14:27:17 +01:00
Tobie Morgan Hitchcock
b5ff2cc1cb Enable text formatting for some sql ast structs 2016-10-14 22:53:27 +01:00
Tobie Morgan Hitchcock
a38e337513 Add SQL SCOPE query ast 2016-10-14 22:21:25 +01:00
Tobie Morgan Hitchcock
8ebc77465c Add SQL LIVE query ast 2016-10-14 22:21:17 +01:00
Tobie Morgan Hitchcock
a4520ca669 Add reserved keywords for SCOPE queries 2016-10-14 22:21:05 +01:00
Tobie Morgan Hitchcock
99012cb015 Add LIVE as reserved sql keyword 2016-10-14 22:17:58 +01:00
Tobie Morgan Hitchcock
9d490950a4 Add SQL VIEW to sql tests 2016-10-14 22:15:40 +01:00
Tobie Morgan Hitchcock
4e20db990a Add IF to sql reserved words 2016-10-14 22:06:05 +01:00
Tobie Morgan Hitchcock
115c97ce86 Remove code in rules and use SQL WHERE clause 2016-10-14 22:05:44 +01:00
Tobie Morgan Hitchcock
a16f7b2aba Add SCHEMALESS / SCHEMAFULL support to queries 2016-10-14 21:31:45 +01:00
Tobie Morgan Hitchcock
daa8db511c Add RETURN INFO command to sql queries 2016-10-14 08:01:56 +01:00
Tobie Morgan Hitchcock
f23d1e10d7 Use int64 instead of float64 for non decimal numbers 2016-10-14 07:55:53 +01:00
Tobie Morgan Hitchcock
6da2e371ca Remove RECORD keyword 2016-10-14 07:54:26 +01:00
Tobie Morgan Hitchcock
dd79f3c440 Remove SQL RECORD statement 2016-10-07 14:21:01 +01:00
Tobie Morgan Hitchcock
25c86a49da Use cork serialization for data storage 2016-10-02 00:17:19 +01:00
Tobie Morgan Hitchcock
bbae9a5fac Enable ability to RETURN INFO 2016-09-21 17:56:27 +01:00
Tobie Morgan Hitchcock
504c1b81e2 Simplify code 2016-09-21 00:37:03 +01:00
Tobie Morgan Hitchcock
66f09db9f5 Add SQL VIEWs 2016-09-21 00:36:37 +01:00
Tobie Morgan Hitchcock
f37ec653d1 Remove SQL EXPLAIN command 2016-09-21 00:34:21 +01:00
Tobie Morgan Hitchcock
bde073cd36 Update SQL ASTs 2016-09-21 00:25:39 +01:00
Tobie Morgan Hitchcock
7d5bff29aa Add additional sql functions 2016-09-21 00:24:03 +01:00
Tobie Morgan Hitchcock
20fe168587 Remove unused EAT @ token 2016-09-20 14:03:53 +01:00
Tobie Morgan Hitchcock
9436a752d8 Alow @thing to be used as DEFAULT values in fields 2016-09-19 14:47:11 +01:00
Tobie Morgan Hitchcock
3089b6460f Switch SQL RULES and SQL TABLE order 2016-09-19 11:12:08 +01:00
Tobie Morgan Hitchcock
ab30c6b85e Add SQL INFO query command 2016-09-19 11:08:44 +01:00
Tobie Morgan Hitchcock
3bbfa7919a Update Statement ASTs 2016-09-14 22:23:02 +01:00
Tobie Morgan Hitchcock
1fc814bb43 Parse tables and @things better 2016-09-14 22:22:31 +01:00
Tobie Morgan Hitchcock
974f75eea0 Uunexport methods which don’t need to be public 2016-09-14 22:21:25 +01:00
Tobie Morgan Hitchcock
9bbbf4491a Ensure parsed times are stored in UTC 2016-09-14 21:57:42 +01:00
Tobie Morgan Hitchcock
9940640a45 Remove unused token 2016-09-14 21:50:04 +01:00
Tobie Morgan Hitchcock
0a7e93d799 Allow bound params for DIFF, MERGE, CONTENT 2016-09-14 21:49:27 +01:00
Tobie Morgan Hitchcock
19d7c2a14e Don’t embed document data 2016-09-14 21:46:23 +01:00
Tobie Morgan Hitchcock
48b644f399 Remove RESYNC INDEX command 2016-09-14 10:23:57 +01:00
Tobie Morgan Hitchcock
4836c498a4 Enable parsing tables as struct not string 2016-09-07 17:01:32 +01:00
Tobie Morgan Hitchcock
b82216af21 Enable setting fields to record ids 2016-09-07 16:59:01 +01:00
Tobie Morgan Hitchcock
9492ed7244 Update SQL tests 2016-09-07 16:58:50 +01:00
Tobie Morgan Hitchcock
2fb4791387 Allow modifying whole tables with DIFFs 2016-09-07 16:58:37 +01:00
Tobie Morgan Hitchcock
020dbbe0c2 Allow numbers, dates, times as table names 2016-09-07 16:58:25 +01:00
Tobie Morgan Hitchcock
f8562f1ccb Parse record ids whole instead of seperately 2016-09-07 16:58:05 +01:00
Tobie Morgan Hitchcock
1219b3825f Use values parsed in scanner instead of reparsing 2016-09-07 16:53:04 +01:00
Tobie Morgan Hitchcock
af4281c920 Enable bound parameters in sql queries 2016-09-07 16:44:23 +01:00