skip to Main Content

Postgresql – Entity to support multiple dialects

I have an SQLAlchemy entity written for PostgreSQL dialect and it uses server_default=func.clock_timestamp(): row_created = sa.Column('row_created_', sa.DateTime(timezone=True), server_default=func.clock_timestamp(), nullable=False) I also need to use it with SQLite, which throws an error: sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) unknown function: clock_timestamp() How do I make…

VIEW QUESTION

Telegram – Django ORM Q and Async

I'm using django with Telegram Bot If i need to make ORM Query, i can do it like that all_offers = await sync_to_async(Offers.objects.filter, thread_sensitive=True)( status = True, ) but not i need to make more difficult query with Q function…

VIEW QUESTION

Should CakePHP 4 always eager load associations?

In my CakePHP 4 project, I have two models with a one-to-many relationship between them: <?php namespace AppModelTable; use CakeORMTable; class ContentsTable extends Table { public function initialize(array $config): void { parent::initialize($config); $this->setTable('contents'); $this->setPrimaryKey('id'); // more relations here $this->belongsTo('ContentTypes', […

VIEW QUESTION

Django ORM: move filter after annotate subquery – Postgresql

This Django ORM statement: Model.objects.all() .annotate( ord=Window( expression=RowNumber(), partition_by=F('related_id'), order_by=[F("date_created").desc()] ) ) .filter(ord=1) .filter(date_created__lte=some_datetime) Leads to the following SQL query: SELECT * FROM ( SELECT id, related_id, values, date_created ROW_NUMBER() OVER ( PARTITION BY related_id ORDER BY date_created DESC )…

VIEW QUESTION
Back To Top
Search