sync: 鍚屾灞€鍩熺綉鏈€鏂颁唬鐮?(source master @ b69568e4)
This commit is contained in:
1 parent
4f7f07504a
commit
8bc8b0e082
1651 files changed
+278599
-11416
No files matched your search
+29
@@ -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
|
||||
|
||||
Reference in new issue
Block a user