selda-postgresql 0.1.8.2 → 0.1.8.3
raw patch · 3 files changed
+40/−23 lines, 3 filesdep ~bytestringdep ~postgresql-binarydep ~postgresql-libpqnew-uploader
Dependency ranges changed: bytestring, postgresql-binary, postgresql-libpq, text, time
Files
- LICENSE +21/−0
- selda-postgresql.cabal +12/−17
- src/Database/Selda/PostgreSQL.hs +7/−6
+ LICENSE view
@@ -0,0 +1,21 @@+MIT License++Copyright (c) 2017-2019 Anton Ekblad++Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in all+copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE+SOFTWARE.
selda-postgresql.cabal view
@@ -1,21 +1,18 @@ name: selda-postgresql-version: 0.1.8.2+version: 0.1.8.3 synopsis: PostgreSQL backend for the Selda database EDSL. description: PostgreSQL backend for the Selda database EDSL. Requires the PostgreSQL @libpq@ development libraries to be installed. homepage: https://github.com/valderman/selda license: MIT+license-file: LICENSE author: Anton Ekblad maintainer: anton@ekblad.cc category: Database build-type: Simple cabal-version: >=1.10 -flag haste- default: False- description: Package is being installed for Haste.- library exposed-modules: Database.Selda.PostgreSQL@@ -27,18 +24,16 @@ OverloadedStrings CPP build-depends:- base >=4.9 && <5- , bytestring >=0.9 && <0.12- , exceptions >=0.8 && <0.11- , selda >=0.5 && <0.6- , selda-json >=0.1 && <0.2- , text >=1.0 && <1.3- if !flag(haste)- build-depends:- postgresql-binary >=0.12 && <0.13- , postgresql-libpq >=0.9 && <0.10- , time >=1.5 && <1.12- , uuid-types >=1.0 && <1.1+ base >=4.9 && <5+ , bytestring >=0.9 && <0.13+ , exceptions >=0.8 && <0.11+ , selda >=0.5 && <0.6+ , selda-json >=0.1 && <0.2+ , text >=1.0 && <2.2+ , postgresql-binary >=0.12 && <0.15+ , postgresql-libpq >=0.9 && <0.12+ , time >=1.5 && <1.16+ , uuid-types >=1.0 && <1.1 hs-source-dirs: src default-language:
src/Database/Selda/PostgreSQL.hs view
@@ -192,7 +192,7 @@ bigserialQue :: [ColAttr] bigserialQue = [AutoPrimary Strong, Required] - -- For when we use 'autoPrimaryGen' on 'Int' field+ -- For when we use 'autoPrimary' on 'Int' field isGenericIntPrimaryKey :: SqlTypeRep -> [ColAttr] -> Bool isGenericIntPrimaryKey ty attrs = ty == TInt64 && and ((`elem` attrs) <$> bigserialQue) @@ -274,13 +274,12 @@ Right (_, fks) <- pgQueryRunner c False fkquery [] Right (_, ixs) <- pgQueryRunner c False ixquery [] colInfos <- mapM (describe fks (map toText ixs)) vals- x <- pure $ TableInfo+ pure $ TableInfo { tableInfoName = mkTableName tbl , tableColumnInfos = colInfos , tableUniqueGroups = map (map mkColName) uniques , tablePrimaryKey = [mkColName pk | [SqlString pk] <- pkInfo] }- pure x where splitNames = breakNames . toText -- TODO: this is super ugly; should really be fixed@@ -294,7 +293,9 @@ tableinfo = mconcat [ "SELECT column_name, data_type, is_nullable, column_default LIKE 'nextval(%' " , "FROM information_schema.columns "- , "WHERE table_name = '", tbl, "';"+ , "WHERE table_name = '", tbl, "' "+ , "AND table_schema = current_schema() "+ , "ORDER BY ordinal_position;" ] pkquery = mconcat [ "SELECT a.attname "@@ -321,7 +322,7 @@ , " ON tc.constraint_name = kcu.constraint_name " , "JOIN information_schema.constraint_column_usage AS ccu " , " ON ccu.constraint_name = tc.constraint_name "- , "WHERE constraint_type = 'FOREIGN KEY' AND tc.table_name='", tbl, "';"+ , "WHERE constraint_type = 'FOREIGN KEY' AND tc.table_name='", tbl, "' AND tc.table_schema=current_schema();" ] ixquery = mconcat [ "select a.attname as column_name "@@ -335,7 +336,7 @@ , "and not ix.indisunique " , "and not ix.indisprimary " , "and t.relkind = 'r' "- , "and t.relname = '", tbl , "';"+ , "and t.oid = '\"", tbl , "\"'::regclass;" ] describe fks ixs [SqlString name, SqlString ty, SqlString nullable, auto] = return $ ColumnInfo