We're supporting both Postgres and SQLite in our application. For the most part, sticking close to ANSI has made this pretty seamless. However, there have been occasions where we want to write either DDL or DML in a dialect-specific way.
For column data, we want to enable the use of JSON. However, when on Postgres we'd like to use JSONB, but when on SQLite we'd use their JSON1 extension. The generic JSON type provided by sqlalchemy defaults to the postgres JSON type when on postgres. How can we get it to default to JSONB instead? Using dialect-specific column types in the mapper is a non-starter, because a mapped class (or Core table) may have to work with both a Postgres connection and an SQLite connection in the same program. We almost want to follow[1], except that I'm concerned that some of the query syntax renderer might also be affected by switching to JSONB. [1]: https://docs.sqlalchemy.org/en/14/core/compiler.html#changing-compilation-of-types For DML there are a few cases where we'd like to use the on_conflict_do_nothing syntax. However, it isn't available as generic syntax, only dialect-specific syntax. It's not clear how query-generating code can figure out which syntax to use given only a connection. SQA has some support for adding text() to larger queries, but this is a modifier that doesn't clearly fit with the other generative methods that accept text arguments. Is there a way to hack on some extra text into the _post_values_clause that will be supported into the future? Sincerely, -- Jonathan Brandmeyer PlanetiQ -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy/CA%2BXzfko00UCaUn%2B8-KAfWWsqjbj6BG_kLCy0vDa-Sn%2BOteZa4g%40mail.gmail.com.