Skip to content

Semistructured Data support for UPDATE and INSERT #107

@olysyuk

Description

@olysyuk

Hello
I have declared class using declarative_base

from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, VARCHAR, ARRAY

Base = declarative_base()

class Video(Base):
    __tablename__ = 'videos'
    __table_args__ = {'schema': 'public'}
    id = Column(VARCHAR(8192))
    categories = Column(ARRAY(VARCHAR(8192)))

While trying to update existing video I change categories to array:

session = sessionmaker(create_engine(conf['snowflake_url']))()
existing_video = session.query(Video).filter_by(id='1').first()
existing_video.categories = ['category1', 'category2']
session.commit()

As a result I see following statement generated

UPDATE entities.videos SET categories='category1' WHERE entities.videos.id = '1'

I believe that something like this should be instead

UPDATE entities.videos SET categories=ARRAY_CONSTRUCT('category1') WHERE entities.videos.id = '1'

Any support of ARRAY, OBJECT, VARIANT on insert is highly appreciated. For example postgresql has it's own JSON type.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions