Skip to content

Cannot import database when enum type is declared in some schema #1114

@maci3k

Description

@maci3k

Hello,

I like to export and import my database to check it's OK. I have a couple of custom types in it.
I created two sample models to show the problem, one with type in schema, other without.
Build 20180425

Model without schema:

<?xml version="1.0" encoding="UTF-8"?>
<!--
CAUTION: Do not modify this file unless you know what you are doing.
         Unexpected results may occur if the code is changed deliberately.
-->
<dbmodel pgmodeler-ver="0.9.1" last-position="0,0" last-zoom="1"
	 default-schema="public" default-owner="postgres">
<database name="WithoutSchema" is-template="false" allow-conns="true">
</database>

<schema name="public" fill-color="#e1e1e1" sql-disabled="true">
</schema>

<usertype name="WoSchema" configuration="enumeration">
	<schema name="public"/>
	<role name="postgres"/>
	<enumeration values="good,bad"/>
</usertype>

<table name="new_table">
	<schema name="public"/>
	<role name="postgres"/>
	<position x="460" y="360"/>
	<column name="some_id" not-null="true">
		<type name="serial" length="0"/>
	</column>
	<column name="enumer" not-null="true">
		<type name="public.&quot;WoSchema&quot;" length="0"/>
	</column>
	<constraint name="new_table_pk" type="pk-constr" table="public.new_table">
		<columns names="some_id" ref-type="src-columns"/>
	</constraint>
</table>

</dbmodel>

Importing works OK.

Model with schema:

<?xml version="1.0" encoding="UTF-8"?>
<!--
CAUTION: Do not modify this file unless you know what you are doing.
         Unexpected results may occur if the code is changed deliberately.
-->
<dbmodel pgmodeler-ver="0.9.1" last-position="0,0" last-zoom="1"
	 default-schema="public" default-owner="postgres">
<database name="WithSchema" is-template="false" allow-conns="true">
</database>

<schema name="public" fill-color="#e1e1e1" sql-disabled="true">
</schema>

<schema name="TestSchema" rect-visible="true" fill-color="#e1e1e1">
	<role name="postgres"/>
</schema>

<usertype name="SchemaEnum" configuration="enumeration">
	<schema name="&quot;TestSchema&quot;"/>
	<role name="postgres"/>
	<enumeration values="good,bad"/>
</usertype>

<table name="new_table">
	<schema name="&quot;TestSchema&quot;"/>
	<role name="postgres"/>
	<position x="460" y="360"/>
	<column name="some_id" not-null="true">
		<type name="serial" length="0"/>
	</column>
	<column name="enumer" not-null="true">
		<type name="&quot;TestSchema&quot;.&quot;SchemaEnum&quot;" length="0"/>
	</column>
	<constraint name="new_table_pk" type="pk-constr" table="&quot;TestSchema&quot;.new_table">
		<columns names="some_id" ref-type="src-columns"/>
	</constraint>
</table>

</dbmodel>

Error debug while importing:

[26] src/baseobject.cpp (355)
  virtual void BaseObject::setName(const QString&)
    [ERR_ASG_INV_NAME_OBJECT] Assignment of a name which contains invalid characters!

[25] src/databasemodel.cpp (4046)
  Type* DatabaseModel::createType()
    [ERR_ASG_INV_NAME_OBJECT] Assignment of a name which contains invalid characters!
       ** <usertype name="&quot;TestSchema&quot;.&quot;SchemaEnum&quot;" configuration="enumeration">
	<schema name="TestSchema"/>
	<role name="postgres"/>
	<enumeration values="good,bad"/>
</usertype>



[24] src/databaseimporthelper.cpp (1614)
  void DatabaseImportHelper::createType(attribs_map&)
    [ERR_ASG_INV_NAME_OBJECT] Assignment of a name which contains invalid characters!
       ** <usertype name="&quot;TestSchema&quot;.&quot;SchemaEnum&quot;" configuration="enumeration">
	<schema name="TestSchema"/>
	<role name="postgres"/>
	<enumeration values="good,bad"/>
</usertype>



[23] src/databaseimporthelper.cpp (747)
  void DatabaseImportHelper::createObject(attribs_map&)
    [ERR_OBJECT_NOT_IMPORTED] The object `TestSchema."TestSchema"."SchemaEnum"' (Type), oid `27651', could not be imported due to one or more errors! Check the exception stack for more details. `HINT:' if the object somehow references objects in `pg_catalog' or `information_schema' consider enable the importing of system objects.
       ** -- Raw attributes: "TestSchema"."SchemaEnum" (OID: 27651) --
alignment: integer
analyze: 0
by-value: true
category: E
collatable: 
collation: 0
comment: 
configuration: enumeration
default-value: 
delimiter: ,
element: 0
enumeration: true
enumerations: good,bad
input: 3506
internal-length: 4
name: "TestSchema"."SchemaEnum"
object-id: 0
object-type: 17
oid: 27651
output: 3507
owner: 	<role name="postgres"/>

permission: 
pgsql-ver: 10.0
preferred: 
range-attribs: 
receive: 3532
schema: 	<schema name="TestSchema"/>

send: 3533
sql-disabled: 
storage: plain
tpmodin: 0
tpmodout: 0
type-class: 
typeattrib: 
---


[22] src/databaseimporthelper.cpp (378)
  void DatabaseImportHelper::createObjects()
    [ERR_OBJECT_NOT_IMPORTED] The object `TestSchema."TestSchema"."SchemaEnum"' (Type), oid `27651', could not be imported due to one or more errors! Check the exception stack for more details. `HINT:' if the object somehow references objects in `pg_catalog' or `information_schema' consider enable the importing of system objects.
       ** -- Raw attributes: "TestSchema"."SchemaEnum" (OID: 27651) --
alignment: integer
analyze: 0
by-value: true
category: E
collatable: 
collation: 0
comment: 
configuration: enumeration
default-value: 
delimiter: ,
element: 0
enumeration: true
enumerations: good,bad
input: 3506
internal-length: 4
name: "TestSchema"."SchemaEnum"
object-id: 0
object-type: 17
oid: 27651
output: 3507
owner: 	<role name="postgres"/>

permission: 
pgsql-ver: 10.0
preferred: 
range-attribs: 
receive: 3532
schema: 	<schema name="TestSchema"/>

send: 3533
sql-disabled: 
storage: plain
tpmodin: 0
tpmodout: 0
type-class: 
typeattrib: 
---


[21] src/baseobject.cpp (355)
  virtual void BaseObject::setName(const QString&)
    [ERR_ASG_INV_NAME_OBJECT] Assignment of a name which contains invalid characters!

[20] src/databasemodel.cpp (4046)
  Type* DatabaseModel::createType()
    [ERR_ASG_INV_NAME_OBJECT] Assignment of a name which contains invalid characters!
       ** <usertype name="&quot;TestSchema&quot;.&quot;SchemaEnum&quot;" configuration="enumeration">
	<schema name="TestSchema"/>
	<role name="postgres"/>
	<enumeration values="good,bad"/>
</usertype>



[19] src/databaseimporthelper.cpp (1614)
  void DatabaseImportHelper::createType(attribs_map&)
    [ERR_ASG_INV_NAME_OBJECT] Assignment of a name which contains invalid characters!
       ** <usertype name="&quot;TestSchema&quot;.&quot;SchemaEnum&quot;" configuration="enumeration">
	<schema name="TestSchema"/>
	<role name="postgres"/>
	<enumeration values="good,bad"/>
</usertype>



[18] src/databaseimporthelper.cpp (747)
  void DatabaseImportHelper::createObject(attribs_map&)
    [ERR_OBJECT_NOT_IMPORTED] The object `TestSchema."TestSchema"."SchemaEnum"' (Type), oid `27651', could not be imported due to one or more errors! Check the exception stack for more details. `HINT:' if the object somehow references objects in `pg_catalog' or `information_schema' consider enable the importing of system objects.
       ** -- Raw attributes: "TestSchema"."SchemaEnum" (OID: 27651) --
alignment: integer
analyze: 0
by-value: true
category: E
collatable: 
collation: 0
comment: 
configuration: enumeration
default-value: 
delimiter: ,
element: 0
enumeration: true
enumerations: good,bad
input: 3506
internal-length: 4
name: "TestSchema"."SchemaEnum"
object-id: 0
object-type: 17
oid: 27651
output: 3507
owner: 	<role name="postgres"/>

permission: 
pgsql-ver: 10.0
preferred: 
range-attribs: 
receive: 3532
schema: 	<schema name="TestSchema"/>

send: 3533
sql-disabled: 
storage: plain
tpmodin: 0
tpmodout: 0
type-class: 
typeattrib: 
---


[17] src/databaseimporthelper.cpp (847)
  QString DatabaseImportHelper::getDependencyObject(const QString&, ObjectType, bool, bool, bool, attribs_map)
    [ERR_OBJECT_NOT_IMPORTED] The object `TestSchema."TestSchema"."SchemaEnum"' (Type), oid `27651', could not be imported due to one or more errors! Check the exception stack for more details. `HINT:' if the object somehow references objects in `pg_catalog' or `information_schema' consider enable the importing of system objects.

[16] src/databaseimporthelper.cpp (1758)
  void DatabaseImportHelper::createTable(attribs_map&)
    [ERR_OBJECT_NOT_IMPORTED] The object `TestSchema."TestSchema"."SchemaEnum"' (Type), oid `27651', could not be imported due to one or more errors! Check the exception stack for more details. `HINT:' if the object somehow references objects in `pg_catalog' or `information_schema' consider enable the importing of system objects.
       ** <usertype name="&quot;TestSchema&quot;.&quot;SchemaEnum&quot;" configuration="enumeration">
	<schema name="TestSchema"/>
	<role name="postgres"/>
	<enumeration values="good,bad"/>
</usertype>



[15] src/databaseimporthelper.cpp (747)
  void DatabaseImportHelper::createObject(attribs_map&)
    [ERR_OBJECT_NOT_IMPORTED] The object `TestSchema.new_table' (Table), oid `27657', could not be imported due to one or more errors! Check the exception stack for more details. `HINT:' if the object somehow references objects in `pg_catalog' or `information_schema' consider enable the importing of system objects.
       ** -- Raw attributes: new_table (OID: 27657) --
columns: 	<column name="some_id" not-null="true" default-value="nextval('new_table_some_id_seq'::regclass)">
		<type name="integer" length="0"/>
	</column>

comment: 
name: new_table
object-type: 6
oid: 27657
oids: 
owner: 	<role name="postgres"/>

parents: 
permission: 
position: 	<position x="0" y="0"/>

rls-enabled: 
rls-forced: 
row-amount: 0
schema: 	<schema name="TestSchema"/>

sql-disabled: 
tablespace: 
unlogged: 
---


[14] src/databaseimporthelper.cpp (847)
  QString DatabaseImportHelper::getDependencyObject(const QString&, ObjectType, bool, bool, bool, attribs_map)
    [ERR_OBJECT_NOT_IMPORTED] The object `TestSchema.new_table' (Table), oid `27657', could not be imported due to one or more errors! Check the exception stack for more details. `HINT:' if the object somehow references objects in `pg_catalog' or `information_schema' consider enable the importing of system objects.

[13] src/databaseimporthelper.cpp (1482)
  void DatabaseImportHelper::createSequence(attribs_map&)
    [ERR_OBJECT_NOT_IMPORTED] The object `TestSchema.new_table' (Table), oid `27657', could not be imported due to one or more errors! Check the exception stack for more details. `HINT:' if the object somehow references objects in `pg_catalog' or `information_schema' consider enable the importing of system objects.
       ** <usertype name="&quot;TestSchema&quot;.&quot;SchemaEnum&quot;" configuration="enumeration">
	<schema name="TestSchema"/>
	<role name="postgres"/>
	<enumeration values="good,bad"/>
</usertype>



[12] src/databaseimporthelper.cpp (747)
  void DatabaseImportHelper::createObject(attribs_map&)
    [ERR_OBJECT_NOT_IMPORTED] The object `TestSchema.new_table_some_id_seq' (Sequence), oid `27655', could not be imported due to one or more errors! Check the exception stack for more details. `HINT:' if the object somehow references objects in `pg_catalog' or `information_schema' consider enable the importing of system objects.
       ** -- Raw attributes: new_table_some_id_seq (OID: 27655) --
attribute: {1,1,2147483647,1,1,}
comment: 
name: new_table_some_id_seq
object-type: 12
oid: 27655
owner: 	<role name="postgres"/>

owner-col: 
permission: 
schema: 	<schema name="TestSchema"/>

sql-disabled: 
---


[11] src/databaseimporthelper.cpp (378)
  void DatabaseImportHelper::createObjects()
    [ERR_OBJECT_NOT_IMPORTED] The object `TestSchema.new_table_some_id_seq' (Sequence), oid `27655', could not be imported due to one or more errors! Check the exception stack for more details. `HINT:' if the object somehow references objects in `pg_catalog' or `information_schema' consider enable the importing of system objects.
       ** -- Raw attributes: new_table_some_id_seq (OID: 27655) --
attribute: {1,1,2147483647,1,1,}
comment: 
name: new_table_some_id_seq
object-type: 12
oid: 27655
owner: 	<role name="postgres"/>

owner-col: 
permission: 
schema: 	<schema name="TestSchema"/>

sql-disabled: 
---


[10] src/baseobject.cpp (355)
  virtual void BaseObject::setName(const QString&)
    [ERR_ASG_INV_NAME_OBJECT] Assignment of a name which contains invalid characters!

[9] src/databasemodel.cpp (4046)
  Type* DatabaseModel::createType()
    [ERR_ASG_INV_NAME_OBJECT] Assignment of a name which contains invalid characters!
       ** <usertype name="&quot;TestSchema&quot;.&quot;SchemaEnum&quot;" configuration="enumeration">
	<schema name="TestSchema"/>
	<role name="postgres"/>
	<enumeration values="good,bad"/>
</usertype>



[8] src/databaseimporthelper.cpp (1614)
  void DatabaseImportHelper::createType(attribs_map&)
    [ERR_ASG_INV_NAME_OBJECT] Assignment of a name which contains invalid characters!
       ** <usertype name="&quot;TestSchema&quot;.&quot;SchemaEnum&quot;" configuration="enumeration">
	<schema name="TestSchema"/>
	<role name="postgres"/>
	<enumeration values="good,bad"/>
</usertype>



[7] src/databaseimporthelper.cpp (747)
  void DatabaseImportHelper::createObject(attribs_map&)
    [ERR_OBJECT_NOT_IMPORTED] The object `TestSchema."TestSchema"."SchemaEnum"' (Type), oid `27651', could not be imported due to one or more errors! Check the exception stack for more details. `HINT:' if the object somehow references objects in `pg_catalog' or `information_schema' consider enable the importing of system objects.
       ** -- Raw attributes: "TestSchema"."SchemaEnum" (OID: 27651) --
alignment: integer
analyze: 0
by-value: true
category: E
collatable: 
collation: 0
comment: 
configuration: enumeration
default-value: 
delimiter: ,
element: 0
enumeration: true
enumerations: good,bad
input: 3506
internal-length: 4
name: "TestSchema"."SchemaEnum"
object-id: 0
object-type: 17
oid: 27651
output: 3507
owner: 	<role name="postgres"/>

permission: 
pgsql-ver: 10.0
preferred: 
range-attribs: 
receive: 3532
schema: 	<schema name="TestSchema"/>

send: 3533
sql-disabled: 
storage: plain
tpmodin: 0
tpmodout: 0
type-class: 
typeattrib: 
---


[6] src/databaseimporthelper.cpp (847)
  QString DatabaseImportHelper::getDependencyObject(const QString&, ObjectType, bool, bool, bool, attribs_map)
    [ERR_OBJECT_NOT_IMPORTED] The object `TestSchema."TestSchema"."SchemaEnum"' (Type), oid `27651', could not be imported due to one or more errors! Check the exception stack for more details. `HINT:' if the object somehow references objects in `pg_catalog' or `information_schema' consider enable the importing of system objects.

[5] src/databaseimporthelper.cpp (1758)
  void DatabaseImportHelper::createTable(attribs_map&)
    [ERR_OBJECT_NOT_IMPORTED] The object `TestSchema."TestSchema"."SchemaEnum"' (Type), oid `27651', could not be imported due to one or more errors! Check the exception stack for more details. `HINT:' if the object somehow references objects in `pg_catalog' or `information_schema' consider enable the importing of system objects.
       ** <usertype name="&quot;TestSchema&quot;.&quot;SchemaEnum&quot;" configuration="enumeration">
	<schema name="TestSchema"/>
	<role name="postgres"/>
	<enumeration values="good,bad"/>
</usertype>



[4] src/databaseimporthelper.cpp (747)
  void DatabaseImportHelper::createObject(attribs_map&)
    [ERR_OBJECT_NOT_IMPORTED] The object `TestSchema.new_table' (Table), oid `27657', could not be imported due to one or more errors! Check the exception stack for more details. `HINT:' if the object somehow references objects in `pg_catalog' or `information_schema' consider enable the importing of system objects.
       ** -- Raw attributes: new_table (OID: 27657) --
columns: 	<column name="some_id" not-null="true" default-value="nextval('new_table_some_id_seq'::regclass)">
		<type name="integer" length="0"/>
	</column>

comment: 
name: new_table
object-type: 6
oid: 27657
oids: 
owner: 	<role name="postgres"/>

parents: 
permission: 
position: 	<position x="0" y="0"/>

rls-enabled: 
rls-forced: 
row-amount: 0
schema: 	<schema name="TestSchema"/>

sql-disabled: 
tablespace: 
unlogged: 
---


[3] src/databaseimporthelper.cpp (378)
  void DatabaseImportHelper::createObjects()
    [ERR_OBJECT_NOT_IMPORTED] The object `TestSchema.new_table' (Table), oid `27657', could not be imported due to one or more errors! Check the exception stack for more details. `HINT:' if the object somehow references objects in `pg_catalog' or `information_schema' consider enable the importing of system objects.
       ** -- Raw attributes: new_table (OID: 27657) --
columns: 	<column name="some_id" not-null="true" default-value="nextval('new_table_some_id_seq'::regclass)">
		<type name="integer" length="0"/>
	</column>

comment: 
name: new_table
object-type: 6
oid: 27657
oids: 
owner: 	<role name="postgres"/>

parents: 
permission: 
position: 	<position x="0" y="0"/>

rls-enabled: 
rls-forced: 
row-amount: 0
schema: 	<schema name="TestSchema"/>

sql-disabled: 
tablespace: 
unlogged: 
---


[2] src/databaseimporthelper.cpp (397)
  void DatabaseImportHelper::createObjects()
    [ERR_OBJECT_NOT_IMPORTED] The object `TestSchema.new_table' (Table), oid `27657', could not be imported due to one or more errors! Check the exception stack for more details. `HINT:' if the object somehow references objects in `pg_catalog' or `information_schema' consider enable the importing of system objects.

[1] src/databaseimporthelper.cpp (642)
  void DatabaseImportHelper::importDatabase()
    [ERR_OBJECT_NOT_IMPORTED] The object `TestSchema.new_table' (Table), oid `27657', could not be imported due to one or more errors! Check the exception stack for more details. `HINT:' if the object somehow references objects in `pg_catalog' or `information_schema' consider enable the importing of system objects.

[0] src/databaseimportform.cpp (412)
  void DatabaseImportForm::captureThreadError(Exception)
    [ERR_OBJECT_NOT_IMPORTED] The object `TestSchema.new_table' (Table), oid `27657', could not be imported due to one or more errors! Check the exception stack for more details. `HINT:' if the object somehow references objects in `pg_catalog' or `information_schema' consider enable the importing of system objects.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions