diff --git a/src/PgStructure.hs b/src/PgStructure.hs index 5622ae76f..e1daea479 100644 --- a/src/PgStructure.hs +++ b/src/PgStructure.hs @@ -10,8 +10,6 @@ import Data.Maybe (mapMaybe) import Control.Applicative ( (<*>) ) -import Data.HashMap.Strict hiding (map) - import qualified Data.ByteString.Lazy as BL import qualified Data.Aeson as JSON @@ -62,7 +60,7 @@ instance JSON.ToJSON Column where , "precision" .= colPrecision c ] data TableOptions = TableOptions { - tblOptcolumns :: HashMap String Column + tblOptcolumns :: [Column] , tblOptpkey :: [String] } @@ -112,9 +110,6 @@ columns s t conn = do (fromSql precision) mkColumn _ = Nothing -namedColumnHash :: [Column] -> HashMap String Column -namedColumnHash = fromList . (Prelude.zip =<< Prelude.map colName) - printTables :: String -> Connection -> IO BL.ByteString printTables schema conn = JSON.encode <$> tables schema conn @@ -122,8 +117,8 @@ printColumns :: String -> String -> Connection -> IO BL.ByteString printColumns schema table conn = JSON.encode <$> (TableOptions <$> cols <*> pkey) where - cols :: IO (HashMap String Column) - cols = namedColumnHash <$> columns schema table conn + cols :: IO [Column] + cols = columns schema table conn pkey :: IO [String] pkey = primaryKeyColumns schema table conn diff --git a/test/Feature/StructureSpec.hs b/test/Feature/StructureSpec.hs index 89b44af3d..aff595f5d 100644 --- a/test/Feature/StructureSpec.hs +++ b/test/Feature/StructureSpec.hs @@ -29,42 +29,44 @@ spec = around appWithFixture $ do request methodOptions "/auto_incrementing_pk" [] "" `shouldRespondWith` [json| { "pkey":["id"], - "columns":{ - "inserted_at":{ - "precision":null, - "updatable":true, - "schema":"1", - "name":"inserted_at", - "type":"timestamp with time zone", - "maxLen":null, - "nullable":true, - "position":4}, - "id":{ - "precision":32, - "updatable":true, - "schema":"1", - "name":"id", - "type":"integer", - "maxLen":null, - "nullable":false, - "position":1}, - "non_nullable_string":{ - "precision":null, - "updatable":true, - "schema":"1", - "name":"non_nullable_string", - "type":"character varying", - "maxLen":null, - "nullable":false, - "position":3}, - "nullable_string":{ - "precision":null, - "updatable":true, - "schema":"1", - "name":"nullable_string", - "type":"character varying", - "maxLen":null, - "nullable":true, - "position":2}} + "columns":[ + { + "precision": 32, + "updatable": true, + "schema": "1", + "name": "id", + "type": "integer", + "maxLen": null, + "nullable": false, + "position": 1 + }, { + "precision": null, + "updatable": true, + "schema": "1", + "name": "nullable_string", + "type": "character varying", + "maxLen": null, + "nullable": true, + "position": 2 + }, { + "precision": null, + "updatable": true, + "schema": "1", + "name": "non_nullable_string", + "type": "character varying", + "maxLen": null, + "nullable": false, + "position": 3 + }, { + "precision": null, + "updatable": true, + "schema": "1", + "name": "inserted_at", + "type": "timestamp with time zone", + "maxLen": null, + "nullable": true, + "position": 4 + } + ] } |]