Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse error when table contains schema #1

Open
srghma opened this issue Sep 10, 2019 · 2 comments
Open

Parse error when table contains schema #1

srghma opened this issue Sep 10, 2019 · 2 comments

Comments

@srghma
Copy link

srghma commented Sep 10, 2019

using

create table app_public.user_oauths (
  id                 uuid         primary key default uuid_generate_v4()
);

with command

sqltopurs -i migrations/0000000002-users/entities/user_oauths/table.up.sql -o migrations/0000000002-users/entities/user_oauths/Table.purs -m Users.Table.purs

results in

[nix-shell:~/projects/greenbadger]$ sqltopurs -i migrations/0000000002-users/entities/user_oauths/table.up.sql -o migrations/0000000002-users/entities/user_oauths/Table.purs -m Users.Table.purs
/nix/store/jkgjqvr68ggr2r25waw2pwvqdghh76f4-greenbadger-modules/node_modules/sqltopurs/sqltopurs.js:660
      throw e;
      ^

Error: Error: ParseError: (ParseError "Expected \"(\"" (Position { line: 1, column: 24 }))
    at Object.exports.error (/nix/store/jkgjqvr68ggr2r25waw2pwvqdghh76f4-greenbadger-modules/node_modules/sqltopurs/sqltopurs.js:651:12)
    at /nix/store/jkgjqvr68ggr2r25waw2pwvqdghh76f4-greenbadger-modules/node_modules/sqltopurs/sqltopurs.js:18854:148
    at /nix/store/jkgjqvr68ggr2r25waw2pwvqdghh76f4-greenbadger-modules/node_modules/sqltopurs/sqltopurs.js:1437:26
    at /nix/store/jkgjqvr68ggr2r25waw2pwvqdghh76f4-greenbadger-modules/node_modules/sqltopurs/sqltopurs.js:18855:101
    at /nix/store/jkgjqvr68ggr2r25waw2pwvqdghh76f4-greenbadger-modules/node_modules/sqltopurs/sqltopurs.js:1440:26
    at /nix/store/jkgjqvr68ggr2r25waw2pwvqdghh76f4-greenbadger-modules/node_modules/sqltopurs/sqltopurs.js:18856:37
    at /nix/store/jkgjqvr68ggr2r25waw2pwvqdghh76f4-greenbadger-modules/node_modules/sqltopurs/sqltopurs.js:517:23
    at /nix/store/jkgjqvr68ggr2r25waw2pwvqdghh76f4-greenbadger-modules/node_modules/sqltopurs/sqltopurs.js:482:7
    at /nix/store/jkgjqvr68ggr2r25waw2pwvqdghh76f4-greenbadger-modules/node_modules/sqltopurs/sqltopurs.js:511:19
    at /nix/store/jkgjqvr68ggr2r25waw2pwvqdghh76f4-greenbadger-modules/node_modules/sqltopurs/sqltopurs.js:517:27
    at Object.exports.error (/nix/store/jkgjqvr68ggr2r25waw2pwvqdghh76f4-greenbadger-modules/node_modules/sqltopurs/sqltopurs.js:651:12)
    at /nix/store/jkgjqvr68ggr2r25waw2pwvqdghh76f4-greenbadger-modules/node_modules/sqltopurs/sqltopurs.js:18832:101
    at /nix/store/jkgjqvr68ggr2r25waw2pwvqdghh76f4-greenbadger-modules/node_modules/sqltopurs/sqltopurs.js:568:11
    at /nix/store/jkgjqvr68ggr2r25waw2pwvqdghh76f4-greenbadger-modules/node_modules/sqltopurs/sqltopurs.js:489:7
    at /nix/store/jkgjqvr68ggr2r25waw2pwvqdghh76f4-greenbadger-modules/node_modules/sqltopurs/sqltopurs.js:511:19
    at /nix/store/jkgjqvr68ggr2r25waw2pwvqdghh76f4-greenbadger-modules/node_modules/sqltopurs/sqltopurs.js:517:27
    at /nix/store/jkgjqvr68ggr2r25waw2pwvqdghh76f4-greenbadger-modules/node_modules/sqltopurs/sqltopurs.js:482:7
    at /nix/store/jkgjqvr68ggr2r25waw2pwvqdghh76f4-greenbadger-modules/node_modules/sqltopurs/sqltopurs.js:511:19
    at /nix/store/jkgjqvr68ggr2r25waw2pwvqdghh76f4-greenbadger-modules/node_modules/sqltopurs/sqltopurs.js:517:27
    at /nix/store/jkgjqvr68ggr2r25waw2pwvqdghh76f4-greenbadger-modules/node_modules/sqltopurs/sqltopurs.js:482:7

using

create table user_oauths (
  id                 uuid         primary key default uuid_generate_v4()
);

with same command

results in empty file (error too)

module Users.Table.purs where
import Prelude ((<$>), map, (<*>))
import Control.Monad.Except (withExcept)
import Database.Postgres (Client, DB, query, Query(Query), queryOne)
import Control.Monad.Aff (Aff)
import Data.Maybe (Maybe)
import Data.Foreign (F, ForeignError(..))
import Data.Newtype (class Newtype, unwrap)
import Database.Postgres.SqlValue (toSql, readSqlProp, fromSql, class IsSqlValue)

-- Table newtypes

-- CRUD definitions

-- PGSQL Function definitions
@srghma
Copy link
Author

srghma commented Sep 10, 2019

Im thinking, wouldnt it be easier to generate not from parsed sql file, but from connection

I mean definitions of all functions and tables

like this does https://github.com/SweetIQ/schemats

@srghma
Copy link
Author

srghma commented Sep 10, 2019

I can't believe no one has written something like this for Haskell

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant