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

import failed - pq argument of AND must be type boolean #6

Closed
richp10 opened this issue Oct 29, 2021 · 4 comments
Closed

import failed - pq argument of AND must be type boolean #6

richp10 opened this issue Oct 29, 2021 · 4 comments

Comments

@richp10
Copy link

richp10 commented Oct 29, 2021

Attempting to import from a postgres 13 database with this command:

go run ariga.io/entimport/cmd/entimport -dialect postgres -dsn "host=localhost port=5432 user=postgres dbname=testdb password=tesdbPass sslmode=disable" -tables "services"

It crashes with the error:
entimport: schema import failed - postgres: querying schema tables: pq: argument of AND must be type boolean, not type information_schema.sql_identifier

If I do not include the -tables param, it crashes with:
schema import failed - entimport: invalid primary key - single part key must be present

@richp10
Copy link
Author

richp10 commented Oct 29, 2021

I found that a table did not have a primary key - after adding this the result without specifying tables is:

entimport: schema writing failed - schemast: unsupported type TypeBytes

And if I specify a table (which I have checked does not have a Bytes field) I still get the other error:

entimport: schema import failed - postgres: querying schema tables: pq: argument of AND must be type boolean, not type information_schema.sql_identifier

@zeevmoney
Copy link
Contributor

Hi @richp10
Thanks for reaching out.

  • The unsupported type TypeBytes error, the error is related to the fact that I didn't implement support for all fields yet, please see my reply here.

  • About the other error, can you please share your schema and exact postgres version?

@richp10
Copy link
Author

richp10 commented Nov 1, 2021

Thanks.. I have removed all the bytea fields so that is no longer an issue.

On the other error, it is still showing even without the byea fields and fixed primary keys. This is the DDL of one table that showed the same result with -tables "blogs"

SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;

CREATE TABLE public.blogs (
    id integer NOT NULL,
    title character varying(50),
    body text,
    created_at timestamp without time zone DEFAULT now(),
    updated_at timestamp without time zone DEFAULT now(),
    slug character varying(55),
    key_words character varying(1000)
);

There are triggers to update the timestamps, and also to set the ID from a sequence - not included for clarity but let me know if you want a look.

The tables are in the 'public' schema (I tried table name as 'public.blogs' but it made no difference).

I am running PostgreSQL 13.4 on Windows

Let me know if there is anything else I can do to check / help - the project looks terrific and my schema is large and hand coding for ent would be a massive PITA !

@zeevmoney
Copy link
Contributor

Hi again, and sorry for the long reply.
We did some recent updates to Atlas and I've updated this package.
Tried your schema:

SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;

CREATE TABLE public.blogs
(
    id         integer NOT NULL,
    title      character varying(50),
    body       text,
    created_at timestamp without time zone DEFAULT now(),
    updated_at timestamp without time zone DEFAULT now(),
    slug       character varying(55),
    key_words  character varying(1000)
);

And go the follwoing:

// Code generated by entimport, DO NOT EDIT.

package schema

import (
	"entgo.io/ent"
	"entgo.io/ent/schema"
	"entgo.io/ent/schema/field"
)

type Blog struct {
	ent.Schema
}

func (Blog) Fields() []ent.Field {
	return []ent.Field{field.Int32("id"),
		field.String("title").Optional(),
		field.String("body").Optional(),
		field.Time("created_at").Optional(),
		field.Time("updated_at").Optional(),
		field.String("slug").Optional(),
		field.String("key_words").Optional()}
}
func (Blog) Edges() []ent.Edge {
	return nil
}
func (Blog) Annotations() []schema.Annotation {
	return nil
}

Try to update entimport to the latest version and run it again, should work fine now (except for the bytes field of course).

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

2 participants