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

generate_mapping error #251

Closed
stsouko opened this Issue Apr 1, 2017 · 12 comments

Comments

Projects
None yet
5 participants
@stsouko
Copy link

stsouko commented Apr 1, 2017

I use postgres schemas.

_table_ = (schema, 'molecule')

and then I run generate_mapping(create_tables=True) on existing db with tables I receive:

DBSchemaError: Table "db_data"."molecule" cannot be created, because table "molecule" (with a different letter case) already exists in the database. Try to delete "molecule" table first.

but without schemas this works fine.

@newJerseyan

This comment has been minimized.

Copy link

newJerseyan commented Jul 18, 2017

Unfortunately, I am experiencing the same issue.

I adhered to schema support format illustrated in the examples in the official ponyorm repo (https://github.com/ponyorm/pony/blob/orm/pony/orm/examples/university1.py on line 33).

There is no problem with creating the tables for the first time but whenever this script is run again, e.g., when importing it into another script which populates the database, it crashes.
Although manually checking would be a (cumbersome) alternative, the expected behavior of the generate_mapping(create_tables=True) method as far as I have interpreted it is to only try generating the tables if they do not yet exists.

I am grateful for any suggestions on how to solve this elegantly. Thanks!

@stsouko

This comment has been minimized.

Copy link
Author

stsouko commented Jul 18, 2017

currently I use separate function in setup file of my app for map generation on first run.

@christosR

This comment has been minimized.

Copy link

christosR commented Feb 8, 2018

any update on this? I have the same issue with postgres

@christosR

This comment has been minimized.

Copy link

christosR commented Feb 9, 2018

when using table = (schema, 'tablename')
line 58 in dbschema.py compares a tuple with a string and the comparison fails.
The second element of the tuple is the actual table-name in the correct case.

@kozlovsky kozlovsky closed this in 310995c Feb 9, 2018

@kozlovsky

This comment has been minimized.

Copy link
Member

kozlovsky commented Feb 9, 2018

Hi, sorry for the long delay with response. I fixed the code, now tables with explicitly specified schema name should be created without errors

@christosR

This comment has been minimized.

Copy link

christosR commented Feb 9, 2018

thank you, will give it a shot

@christosR

This comment has been minimized.

Copy link

christosR commented Feb 20, 2018

are you going to release anytime soon?

@kozlovsky

This comment has been minimized.

Copy link
Member

kozlovsky commented Feb 20, 2018

I hope I can do release tomorrow

@christosR

This comment has been minimized.

Copy link

christosR commented Feb 20, 2018

that would be great! ty

@pieterdb

This comment has been minimized.

Copy link

pieterdb commented Feb 27, 2018

Any chance we can get that release? I'm having the same issue.
Thanks!

@kozlovsky

This comment has been minimized.

Copy link
Member

kozlovsky commented Feb 27, 2018

Tomorrow's day will be dedicated to the release

@pieterdb

This comment has been minimized.

Copy link

pieterdb commented Feb 28, 2018

Thanks for the update !
I'm keeping my fingers crossed for that release then.

@kozlovsky kozlovsky added the bug label Mar 17, 2018

@kozlovsky kozlovsky added this to the 0.7.4 milestone Mar 17, 2018

kozlovsky added a commit that referenced this issue Jul 23, 2018

Pony ORM Release 0.7.4 (2018-07-23)
# Major features

* Hybrid methods and properties added: https://docs.ponyorm.com/entities.html#hybrid-methods-and-properties
* Allow to base queries on another queries: `select(x.a for x in prev_query if x.b)`
* Added support of Python 3.7
* Added support of PyPy
* `group_concat()` aggregate function added
* pony.flask subpackage added for integration with Flask

# Other features

* `distinct` option added to aggregate functions
* Support of explicit casting to `float` and `bool` in queries

# Improvements

* Apply @cut_traceback decorator only when pony.MODE is 'INTERACTIVE'

# Bugfixes

* In SQLite3 `LIKE` is case sensitive now
* #249: Fix incorrect mixin used for Timedelta
* #251: correct dealing with qualified table names
* #301: Fix aggregation over JSON Column
* #306: Support of frozenset constants added
* #308: Fixed an error when assigning JSON attribute value to the same attribute: obj.json_attr = obj.json_attr
* #313: Fix missed retry on exception raised during db_session.__exit__
* #314: Fix AttributeError: 'NoneType' object has no attribute 'seeds'
* #315: Fix attribute lifting for JSON attributes
* #321: Fix KeyError on obj.delete()
* #325: duplicating percentage sign in raw SQL queries without parameters
* #331: Overriding __len__ in entity fails
* #336: entity declaration serialization
* #357: reconnect after PostgreSQL server closed the connection unexpectedly
* Fix Python implementation of between() function and rename arguments: between(a, x, y) -> between(x, a, b)
* Fix retry handling: in PostgreSQL and Oracle an error can be raised during commit
* Fix optimistic update checks for composite foreign keys
* Don't raise OptimisticCheckError if db_session is not optimistic
* Handling incorrect datetime values in MySQL
* Improved ImportError exception messages when MySQLdb, pymysql, psycopg2 or psycopg2cffi driver was not found
* desc() function fixed to allow reverse its effect by calling desc(desc(x))
* __contains__ method should check if objects belong to the same db_session
* Fix pony.MODE detection; mod_wsgi detection according to official doc
* A lot of inner fixes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.