1
Fork 0
Commit graph

252 commits

Author SHA1 Message Date
Jake Wheat e6e8264b3d add support for column constraints in create table 2015-08-02 19:27:39 +03:00
Jake Wheat 4f80ec96d4 add generation clause support to create table 2015-08-02 18:14:45 +03:00
Jake Wheat e495e240c0 add default and identity to create table 2015-08-02 18:04:40 +03:00
Jake Wheat 3b5deec2e5 fix positioning in lexer? and fix line comment token missing trailing \n 2015-08-02 15:29:35 +03:00
Jake Wheat 6802aaef5a add simple create table support 2015-08-01 23:16:26 +03:00
Jake Wheat dfa84072dc start adding basic dml
parser and pretty printer for statements
add query statement
add support for
  insert
  update
  delete
  truncate
bonus ddl:
  limited create schema
  drop schema

add grammar notes to the new test files
2015-08-01 20:26:00 +03:00
Jake Wheat 6fc8869f73 preparation for non-queries
some docs in the lexer
bump the version to 0.5.0
add placeholder files for the planned initial non query support
2015-08-01 18:08:54 +03:00
Jake Wheat bbb793c160 small fixes
fix positions?
small fixes to haddock
add notes to top of lexer module
simplify line comment lexer
remove some trys from lexer
fix the block comment parser to return all the comment text when there
  are embedded / * in the comment
refactor the symbol, keyword and identifier blacklist checking into
  the low level token parsers instead of a separate step using guard
2015-08-01 13:22:07 +03:00
Jake Wheat 913fce068b small fixes
work on the haddock
remove the old attoparsec position stuff from the lexer
change the lexer to accept position info in the same way as the parser
replace sqlindent with new test exe which can parse, lex and indent
2015-08-01 12:13:53 +03:00
Jake Wheat 2df76e3095 add separate lexer 2015-08-01 00:04:18 +03:00
Jake Wheat 2e6f2fc3f2 update changelog 2015-03-14 16:15:37 +02:00
Jake Wheat db00d50d92 Merge branch 'master' of https://github.com/hanjoosten/simple-sql-parser into hanjoosten-master 2015-03-14 15:39:54 +02:00
Han Joosten dc5ca57124 Introduced QEComment, constructor, likewise the VEComment constructor 2015-03-14 14:28:05 +01:00
Jake Wheat 933964e074 Merge branch 'master' of https://github.com/hanjoosten/simple-sql-parser into hanjoosten-master 2015-03-14 14:06:47 +02:00
Han Joosten 258eff5298 Introduction of Comment in syntax, to facilitate comments in programatically generated SQL 2015-03-14 12:40:35 +01:00
Jake Wheat 3bf4fdbe52 notes 2014-09-13 10:45:45 +03:00
Jake Wheat ba331af24b move limit to only be reserved word in mysql dialect 2014-06-28 15:43:30 +03:00
Jake Wheat c1c514af35 example how to switch parsing and pretty printing depending on dialect 2014-06-28 15:41:11 +03:00
Jake Wheat 7d63c8f8e5 start on dialect prototype code 2014-06-27 12:19:15 +03:00
Jake Wheat 7914898cc8 update to accept latest mtl 2014-06-20 12:27:23 +03:00
Jake Wheat 8996230093 make the typename and app parsers a bit more regular 2014-05-12 22:06:29 +03:00
Jake Wheat 6c9a291930 refactor the filter parsing 2014-05-10 10:02:16 +03:00
Jake Wheat 7f90318647 refactor the app/agg/window parsing 2014-05-09 23:26:18 +03:00
Jake Wheat 4704ccc28e create separate module for generic parser combinator utility functions
create separate module for the error formatting wrapper
heavily refactor the typename parser to remove almost all trys,
  convert to applicative only, and left factor nicely
other refactoring to use more idiomatic parsing and to convert to
  applicative only
2014-05-09 21:37:09 +03:00
Jake Wheat 9ee2a1beab start reworking some of the combinators 2014-05-07 21:53:24 +03:00
Jake Wheat dbd48baaa1 rename LobTypeName to PrecLengthTypeName
rename LobMultiplier and LobUnits to PrecMultiplier and PrecUnits
remove support for limit syntax
remove the unreserved keyword list since it isn't useful
tests for row value constructors
tests for table value constructors
tests for query specifications
tests for explicit table
work on tests for setops,order by,offset,fetch and sort specification
2014-04-20 23:14:55 +03:00
Jake Wheat be79448414 update the reserved keywords to 2011 list 2014-04-20 19:38:43 +03:00
Jake Wheat 9b2ba2fb36 remove ref typename for consistency
support t and p multipliers in lob lengths
update a few tests
2014-04-20 19:24:03 +03:00
Jake Wheat 7a7f4ba7aa work around for haddock refusal to parse literal comment lines with *
in first character position
get rid of code_units since these are not in sql2011
implement next value for
parse the nullary functions with reserved names
updates to the sql2003 file
2014-04-19 21:17:19 +03:00
Jake Wheat 7057241974 add filter and within group aggregates 2014-04-19 18:01:49 +03:00
Jake Wheat 59826ecce2 more docs in Parser.lhs 2014-04-19 15:10:45 +03:00
Jake Wheat ddfac442ab rename some functions in parser 2014-04-19 13:22:11 +03:00
Jake Wheat 445c10a01d rearrange part of the parser file 2014-04-19 13:10:46 +03:00
Jake Wheat fdb90c0440 change collate and in chartype to be a list of names
rearrange and add notes to the parser
2014-04-19 12:47:25 +03:00
Jake Wheat fea6e347bd change joins so natural is represented by separate field to on/using
some fixes and tweaks to the reserved keyword handling, especially in
  the typename parser
2014-04-19 11:18:29 +03:00
Jake Wheat 5d9a32a91d reserve most of the reserved keywords in the parser 2014-04-19 00:18:15 +03:00
Jake Wheat 6b5a29c052 update docs 2014-04-18 23:51:05 +03:00
Jake Wheat 7a84704516 implement reference type name (I think - cannot find any examples or
explanation of what it means, didn't try reading the standard
  itself, just the grammar)
2014-04-18 21:48:14 +03:00
Jake Wheat 3b86a06e5c implement complete interval literals 2014-04-18 21:38:24 +03:00
Jake Wheat f64632bbac support two double quotes in quoted identifier plus unicode quoted identifier syntax 2014-04-18 21:09:46 +03:00
Jake Wheat 4e1a1da820 basic multiset support 2014-04-18 20:50:24 +03:00
Jake Wheat 2ff8580dbf complete basic typename support 2014-04-18 19:49:00 +03:00
Jake Wheat fbdcacc604 modify basic typenames to support dotted names in the syntax
add syntax for most of the other kinds of typenames
add pretty printing for these
todo: the parsing and the tests
2014-04-18 17:55:56 +03:00
Jake Wheat 438e3383e4 fix/work around issues with the keywords parsing
fix the infix and postfix keywords parsing
minor refactoring
2014-04-18 17:51:57 +03:00
Jake Wheat b0f1e044b4 refactor some of the multi keyword/ multiword typename parsing 2014-04-18 14:50:54 +03:00
Jake Wheat 247c7a26b7 improve error messages 2014-04-18 12:28:05 +03:00
Jake Wheat 2cad424379 change the names in the ast to be lists so can support qualified names
everywhere:
  TRSimple: replaces the TRQualified
  Iden
  App name
  AggregateApp name
  WindowApp name
  operator names (not sure if this is used in ansi sql)
  explicit table
  function in from clause
2014-04-18 11:43:37 +03:00
Jake Wheat 3df87a3cf9 change set quantifier and sort direction to represent default separately 2014-04-18 11:18:21 +03:00
Jake Wheat c814cc9437 tweak to error message for reserved keyword as identifier
add in some group by and order by tests
2014-04-18 10:47:39 +03:00
Jake Wheat 37dca6596b support character set literals, e.g. N'stuff'
support collate postfix operator
support escape and uescape as postfix operators
change the collate support in substring and trim which isn't a special
  case in the sql 2003 grammar anymore but just a normal collate postfix
  operator, the old code had the collation name as a string, but the
  new style is as an identifier
2014-04-18 00:16:24 +03:00
Jake Wheat 211174cfb4 work on array constructors and expressions 2014-04-17 22:57:33 +03:00
Jake Wheat d38a5a743a move the typed literal parser around
implement unique predicate, match predicate
change the representation of quantified comparison predicates
2014-04-17 22:35:43 +03:00
Jake Wheat 0d3f552ede move typed lit 2014-04-17 21:42:07 +03:00
Jake Wheat 490c84b7f1 split typed literal parser from cast parser 2014-04-17 21:27:54 +03:00
Jake Wheat df1f948b5d left factor identifier and app parsers 2014-04-17 21:05:47 +03:00
Jake Wheat a296b1ec31 left factor terms which start with parens (scalar subquery, paren value expr/row ctors) 2014-04-17 20:59:46 +03:00
Jake Wheat d202458808 refactor the interval literal parser to not use try 2014-04-17 20:53:16 +03:00
Jake Wheat 556f65ee22 refactor the join parsing to left factor and remove try
refactor the string token parser to reduce use of try
2014-04-17 20:46:16 +03:00
Jake Wheat 6720d3e3a3 add support for named host parameters 2014-04-17 19:27:18 +03:00
Jake Wheat 19df6f18aa don't include unfinished tests in the test suite
fix number literals to accept upper case E
implement multi part string literals
fix tests for string literals, typed literals, boolean literals and
  number literals in the sql 2003 tests
2014-04-17 19:19:41 +03:00
Jake Wheat 488310ff6a add some big improvements to parse error messages
change the parser to not attempt to parse the elements following
'from' unless there is a actual 'from'
improve the symbol parser to try to deal with issues when symbols are
  next to eachother with no intervening whitespaces
improve number literal parsing to fail if there are trailing letters
  or digits which aren't part of the number and aren't separated with
  whitespace
add some code to start analysing the quality of parse error messages
2014-04-17 18:32:41 +03:00
Jake Wheat dffd7b0d7a refactor more of the parser to update with ideas from the tutorial
parser
remove a huge number of 'try' calls in the parser
rename some of the parser functions which used prefix s to nicer names
2014-04-16 20:22:42 +03:00
Jake Wheat 89015144f9 change the ints in the syntax to be integers
partially add buildExprParser hack to deal with some nested prefix and
  postfix unary operators
add new file which starts going through the sql2003 grammar to try to
  create lots of examples for comprehensive testing of sql2003
  support.
replace the lexers with lexers from the tutorial project
2014-04-16 18:58:17 +03:00
Jake Wheat 8b1fa81de7 fix bug in parsing default as all instead of distinct for set operations 2014-04-15 13:47:34 +03:00
Jake Wheat 4989f5251b add Data and Typeable to the syntax 2014-04-10 18:53:11 +03:00
Jake Wheat 79fde02d81 fix default for distinct/all in union in the pretty printer 2014-04-09 18:31:14 +03:00
Sönke Hahn 2e91fb9e81 Allow qualified names ('schema.table') in from clauses 2014-01-22 15:54:14 +08:00
Jake Wheat 9611885448 update changelog, small haddock fixes 2013-12-31 12:20:07 +02:00
Jake Wheat 9e75fa9365 hlint 2013-12-31 11:44:10 +02:00
Jake Wheat 7cf5275615 swap order in select lists so the expression comes first then the alias to match the order in the concrete syntax 2013-12-31 11:31:00 +02:00
Jake Wheat 552d3f5383 use Parser type from Text.Parsec.String, make imports explicit 2013-12-31 11:21:03 +02:00
jake 9d8c1badbd give in and use the parsec buildExpressionParser for now 2013-12-31 11:02:26 +02:00
Jake Wheat 40c64c7631 rename qeFetch to qeFetchFirst 2013-12-19 17:50:25 +02:00
Jake Wheat df7e6f87da change pretty printer to output 'fetch first' instead of 'fetch next' 2013-12-19 12:54:48 +02:00
Jake Wheat 692f8f84ad fixes to haddock and update changelog 2013-12-19 12:15:05 +02:00
Jake Wheat 3b2730fd99 rename ScalarExpr -> ValueExpr which is slightly more standard, add notes on new fixity implementation 2013-12-19 11:46:51 +02:00
Jake Wheat b68c116839 add support for ? for parameterized queries 2013-12-19 10:44:20 +02:00
Jake Wheat 72d7b9428f add parsing for more multi keyword type names 2013-12-19 10:35:38 +02:00
Jake Wheat 1be27eca58 rename Duplicates -> SetQuantifier + qeDuplicates -> qeSetQuantifier 2013-12-19 10:34:32 +02:00
Jake Wheat b631497a04 renames OrderField->SortSpec, InThing->InPredValue 2013-12-18 16:27:06 +02:00
Jake Wheat b89f2a011c fixes for substring, change the abstract syntax for extract and
substring, and add the addition operators position, convert,
  translate, overlay and trim
2013-12-18 15:51:55 +02:00
Jake Wheat 02e8452f8c prepare for the github project name rename to be the same as the haskage package 2013-12-17 22:54:20 +02:00
Jake Wheat bcd06d1ef9 spelling fixes 2013-12-17 22:15:19 +02:00
Jake Wheat 60cf309953 fix haddock, hlint, rename Prec2TypeName to PrecScaleTypeName 2013-12-17 20:46:29 +02:00
Jake Wheat e61672ebf8 hlint 2013-12-17 20:27:11 +02:00
Jake Wheat 558d44140a add support for typenames with precision and scale 2013-12-17 19:52:14 +02:00
Jake Wheat 74c6d39b23 get group by variations working 2013-12-17 19:27:09 +02:00
Jake Wheat b703e04af3 add syntax for new grouping expressions 2013-12-17 19:17:03 +02:00
Jake Wheat 7d094182b7 add support for multiple case when expressions 2013-12-17 18:42:00 +02:00
Jake Wheat ebe522b21d add support for nulls first/last 2013-12-17 18:28:31 +02:00
Jake Wheat e85ab8b831 add names/docs to some of the scalar expr constuctor fields, add partial support for explicit window frames 2013-12-17 17:29:49 +02:00
Jake Wheat bfe07dce53 fix the lateral parsing issue and broken test 2013-12-17 16:33:56 +02:00
Jake Wheat e03090a6a1 add support for rowctor without row, e.g. (1,2) 2013-12-17 16:20:05 +02:00
Jake Wheat 89a4dd0e3e add a few more operators: % & ^ | ~ 2013-12-17 16:15:19 +02:00
Jake Wheat b2728ec9bf add support for ansi standard offset and fetch syntax 2013-12-17 16:00:17 +02:00
Jake Wheat 8093498f2d generalize . to a binary operator 2013-12-17 15:21:43 +02:00
Jake Wheat 8adc169b38 add support for '' in string literals 2013-12-17 15:09:28 +02:00
Jake Wheat 72b67166d9 add support for 'table t' syntax 2013-12-17 13:58:44 +02:00
Jake Wheat 4308acb982 add support for with recursive and column aliases in cte 2013-12-17 13:41:06 +02:00
Jake Wheat c52334943f add support for values 2013-12-17 13:27:16 +02:00
Jake Wheat 4330b3d7e0 add support for quoted identifiers 2013-12-17 13:21:36 +02:00
Jake Wheat 045f2be825 support simple interval literal interval '3 days' and rename CastOp to TypedLit 2013-12-17 12:51:14 +02:00
Jake Wheat 939189a04f partial support for lateral 2013-12-17 12:45:32 +02:00
Jake Wheat d49b3ddb99 add support for functions in tablerefs 2013-12-17 12:33:33 +02:00
Jake Wheat adfeac8d16 parse a join b without inner 2013-12-17 12:27:00 +02:00
Jake Wheat 9461a11c97 get star parsing working everywhere 2013-12-17 12:24:37 +02:00
Jake Wheat 86ba354e26 fix case insensitivity for keyword parsing, add some notes 2013-12-16 13:33:05 +02:00
Jake Wheat 5eb48efb36 reformat 2013-12-16 10:03:46 +02:00
Jake Wheat 3f0ff9aec0 small tidyups 2013-12-14 20:20:41 +02:00
Jake Wheat 3fa7086a48 few small typos, etc. 2013-12-14 17:09:45 +02:00
Jake Wheat b6633bf73c reformat 2013-12-14 16:58:35 +02:00
Jake Wheat 97189fb802 tweak some of the pretty printing 2013-12-14 16:35:36 +02:00
Jake Wheat 730b8a7f0a get fixity adjustment working, fix bug in between parsing 2013-12-14 16:34:57 +02:00
Jake Wheat 9092721ebb get proof of concept fixity handling working 2013-12-14 15:05:52 +02:00
Jake Wheat 4acc59000a improve the pretty printing formatting 2013-12-14 14:24:49 +02:00
Jake Wheat b001276337 work on haddock and a few renames 2013-12-14 14:10:46 +02:00
Jake Wheat c28db4d470 add haddock, reorder the fields in binop and jointref to be more natural 2013-12-14 13:33:15 +02:00
Jake Wheat 65610af74e refactor app parser, from parser 2013-12-14 13:05:02 +02:00
Jake Wheat 3f08adb4c5 work on the semicolon handling 2013-12-14 11:59:29 +02:00
Jake Wheat cd7a15c193 tidy up the number parser 2013-12-14 11:47:13 +02:00
Jake Wheat 8ef799740c refactor the combo query expression parsing and the optional parts of a select query expr 2013-12-14 11:41:58 +02:00
Jake Wheat fabc106fd8 refactor the main scalar expression parser into nicer components 2013-12-14 11:28:45 +02:00
Jake Wheat ac406c077c small refactoring in the parser
factor out the integer parser for interval literals to separate lexer
refactor the app parser to include windows here instead of later on
add notes on the fixity handling
formatting in the cabal file
2013-12-14 11:23:58 +02:00
Jake Wheat 0de32d3429 tidying up 2013-12-14 10:55:44 +02:00
Jake Wheat 0da39d4498 small reformatting 2013-12-14 01:14:23 +02:00
Jake Wheat e80b3606b1 update todo 2013-12-14 01:01:07 +02:00
Jake Wheat 931272d1db add with expressions, all tpch appear to parse correct, some of the later ones pretty print badly though 2013-12-14 00:58:12 +02:00
Jake Wheat 15c83555ff add support for full table aliases 2013-12-14 00:37:34 +02:00
Jake Wheat d005dc1706 work on parsing tpch
add parse function for parsing multiple query expressions separated by
  semicolon
add parser for substring operator
tweak the layout for pretty printing binary operators
add sql file with tpch queries in it
add simple exe to parse and pretty print multiple query expressions
2013-12-14 00:34:05 +02:00
Jake Wheat f08f4eb13b few small fixes
untested fix for case insensitive keywords
add partial support for interval literals
fix bug in prefix operator cast parsing
2013-12-14 00:07:45 +02:00
Jake Wheat 9c4719bda3 add support for union all and union corresponding and for intersect and except 2013-12-13 23:49:22 +02:00
Jake Wheat 1199342477 add support for union,intersect,except 2013-12-13 23:41:12 +02:00
Jake Wheat 64eb5a5c9d add window functions (without frames 2013-12-13 23:31:36 +02:00
Jake Wheat 81e7aa818b add support for extended aggregate syntax 2013-12-13 23:18:30 +02:00
Jake Wheat 5e56a4b560 implement extract 2013-12-13 22:38:43 +02:00
Jake Wheat a001d120c1 tidyups 2013-12-13 22:25:22 +02:00
Jake Wheat b14af47773 add support for a bunch of keyword binary operators 2013-12-13 21:41:50 +02:00
Jake Wheat 546d9b023d add support for more is ... postfix ops 2013-12-13 21:34:59 +02:00
Jake Wheat 4f73f4ec44 split the Op ctor into binop,prefixop, postfixop and specialop
add support for is null
2013-12-13 21:26:14 +02:00
Jake Wheat 955658c41f add support for between 2013-12-13 21:13:36 +02:00
Jake Wheat 386d835cf8 add support for in list, and fix code for in query expr 2013-12-13 21:00:06 +02:00
Jake Wheat 00269617b3 add support for subqueries in scalar expressions 2013-12-13 20:43:28 +02:00
Jake Wheat d6d91b1935 add casts, disable failing tests temporarily 2013-12-13 20:24:20 +02:00
Jake Wheat 99409fbc15 simplify the error position code 2013-12-13 20:08:43 +02:00
Jake Wheat 182526d1fc add parsing for unary + - 2013-12-13 20:01:57 +02:00
Jake Wheat ed47656a0c work on errors 2013-12-13 19:21:44 +02:00
Jake Wheat aa26603a0c start work on cast expressions, add lots more test targets 2013-12-13 18:50:41 +02:00
Jake Wheat a81f62b940 add support for limit and offset 2013-12-13 17:27:02 +02:00
Jake Wheat 1a8551825d add directions to order by 2013-12-13 17:08:10 +02:00
Jake Wheat 2c1eedb70f implement complete base 10 number parser, shorten some syntax names 2013-12-13 17:00:22 +02:00