1
Fork 0

add support for oracle type size units 'char' and 'byte', example: varchar2(55 byte)

This commit is contained in:
Jake Wheat 2016-08-10 11:27:30 +03:00
parent b23f3aaa07
commit ff3dcb814c
4 changed files with 36 additions and 0 deletions

View file

@ -490,7 +490,11 @@ factoring in this function, and it is a little dense.
> <|> PrecT <$ keyword_ "t"
> <|> PrecP <$ keyword_ "p"
> lobUnits = PrecCharacters <$ keyword_ "characters"
> -- char and byte are the oracle spelling
> -- todo: move these to oracle dialect
> <|> PrecCharacters <$ keyword_ "char"
> <|> PrecOctets <$ keyword_ "octets"
> <|> PrecOctets <$ keyword_ "byte"
> tz = True <$ keywords_ ["with", "time","zone"]
> <|> False <$ keywords_ ["without", "time","zone"]
> charSet = keywords_ ["character", "set"] *> names

View file

@ -72,6 +72,7 @@ Test-Suite Tests
Language.SQL.SimpleSQL.GroupBy,
Language.SQL.SimpleSQL.MySQL,
Language.SQL.SimpleSQL.Postgres,
Language.SQL.SimpleSQL.Oracle,
Language.SQL.SimpleSQL.QueryExprComponents,
Language.SQL.SimpleSQL.QueryExprs,
Language.SQL.SimpleSQL.SQL2011Queries,

View file

@ -0,0 +1,29 @@
Tests for oracle dialect parsing
> module Language.SQL.SimpleSQL.Oracle (oracleTests) where
> import Language.SQL.SimpleSQL.TestTypes
> import Language.SQL.SimpleSQL.Syntax
> oracleTests :: TestItem
> oracleTests = Group "oracle dialect"
> [oracleLobUnits]
> oracleLobUnits :: TestItem
> oracleLobUnits = Group "oracleLobUnits" (map (uncurry (TestScalarExpr oracle))
> [("cast (a as varchar2(3 char))"
> ,Cast (Iden [Name Nothing "a"]) (
> PrecLengthTypeName [Name Nothing "varchar2"] 3 Nothing (Just PrecCharacters)))
> ,("cast (a as varchar2(3 byte))"
> ,Cast (Iden [Name Nothing "a"]) (
> PrecLengthTypeName [Name Nothing "varchar2"] 3 Nothing (Just PrecOctets)))
> ]
> ++ [TestStatement oracle
> "create table t (a varchar2(55 BYTE));"
> $ CreateTable [Name Nothing "t"]
> [TableColumnDef $ ColumnDef (Name Nothing "a")
> (PrecLengthTypeName [Name Nothing "varchar2"] 55 Nothing (Just PrecOctets))
> Nothing []]]
> )

View file

@ -37,6 +37,7 @@ test data to the Test.Framework tests.
> import Language.SQL.SimpleSQL.SQL2011Schema
> import Language.SQL.SimpleSQL.MySQL
> import Language.SQL.SimpleSQL.Oracle
Order the tests to start from the simplest first. This is also the
order on the generated documentation.
@ -60,6 +61,7 @@ order on the generated documentation.
> ,sql2011AccessControlTests
> ,sql2011BitsTests
> ,mySQLTests
> ,oracleTests
> ]
> tests :: T.TestTree