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

Alembic downgrade; single qoutes in postgresql #88

Open
TheoLisin opened this issue Nov 27, 2022 · 0 comments
Open

Alembic downgrade; single qoutes in postgresql #88

TheoLisin opened this issue Nov 27, 2022 · 0 comments

Comments

@TheoLisin
Copy link

TheoLisin commented Nov 27, 2022

Hi,
Prior to anything else, I want to thank the developers sincerely <3
Yours tool was quite beneficial to my modest educational project!
Now, back to issues.

Alembic

After applying architect partitions I can't (or didnt notice how) use command alembic downgrade -1, since the previous version of my migration had no knowledge of the additional tables added by the architect tool. Tables are linked, so it's important to delete partitions before the main table.
I found only 2 ways to solve this:

  • manually remove all partitions and then run alembic downgrade -1;
  • change alembic migration script using info about new partitions.

single quotes

I was attempting to use the string_firstchars partition in this manner

@architect.install(
    "partition",
    type="range",
    subtype="string_firstchars",
    constraint="5",
    column="name",
    db=SYNC_SQLALCHEMY_DATABASE_URL,
)
class Author(Base):
    """Author model."""

    __tablename__ = "authors"

    id = Column(Integer, primary_key=True)
    name = Column(String(length=128))

But get an exception because certain authors' names begin with single quotations (e.g. d'Artagnan)

py4j.protocol.Py4JJavaError: An error occurred while calling o54.save. : 
org.apache.spark.SparkException: 
Job aborted due to stage failure: 
Task 2 in stage 1.0 failed 1 times, most recent failure: 
Lost task 2.0 in stage 1.0 (TID 3) (192.168.199.186 executor driver): 
java.sql.BatchUpdateException: 
Batch entry 339 
INSERT INTO authors ("gid","sid","name","orgid","orgs_count","email","organisation","id","id_user") 
VALUES ('5b8695e0e1cd8e14a36f4afa',NULL,'L''Uboš Zelinka','5f71b3031c455f439fe3fd75',0,NULL,'Faculty of Informatics and Information Technologies, Institute of Informatics and Software Engineering, Slovak University of Technology in Bratislava, Bratislava 4, Slovakia 84216',1476131,1476131) 
was aborted: ERROR: syntax error at or near "ub"

I was unable to resolve this issue, so I simply uninstalled architect partitions for that table 👍🏼

Zdorovya vam i vashim blizkim,
TL

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