sync update from LAN repo (source dhk-1 @ 3e87be55)

This commit is contained in:
gozeros committed 2026-10-21 15:06:08 +08:00
1 parent ab6068a7c1
commit 42f2a26fa8
1482 files changed
+227759 -9584

No files matched your search

@@ -0,0 +1,29 @@
"""Runtime compatibility fixes for the official openGauss SQLAlchemy dialect."""
from __future__ import annotations
from sqlalchemy.dialects.postgresql.base import PGTypeCompiler
class DeerFlowOpenGaussTypeCompiler(PGTypeCompiler):
"""Render variable strings without a length for stricter GaussDB variants.
Some GaussDB PostgreSQL-compatible deployments reject ``VARCHAR(n)`` at
the numeric length token even though ordinary PostgreSQL accepts it. A
length-less ``VARCHAR`` keeps the same variable-length string semantics on
openGauss and avoids coupling the schema to that parser difference.
"""
def visit_string(self, type_, **kw): # noqa: ANN001
return "VARCHAR"
def visit_VARCHAR(self, type_, **kw): # noqa: N802, ANN001
return "VARCHAR"
def install_gauss_dialect_compatibility() -> None:
"""Install the compiler only on the openGauss async dialect class."""
from opengauss_sqlalchemy.asyncpg import OpenGaussDialect_asyncpg
OpenGaussDialect_asyncpg.type_compiler_cls = DeerFlowOpenGaussTypeCompiler