Skip to content

feat: format_* signature compliance - ILIKE + Enum + Multirange - #56

Closed
vistart wants to merge 22 commits into
mainfrom
feature/parameter-inline
Closed

vistart wants to merge 22 commits into
mainfrom
feature/parameter-inline

Conversation

@vistart

@vistart vistart commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Format signature compliance for PostgreSQL backend.

vistart and others added 22 commits August 16, 2026 20:50
…ents (#55)

* feat: parallel scenario tests with per-worker database pooling

Wire the testsuite database pool for postgres: register the pool reset
handler, make scenario resolution pool-aware, install core and testsuite
from the feature/parallel-testing branches, and run tests with -n 8.

* fix(test): load testsuite conftest plugin and guard --scenarios registration

Without -p rhosocial.activerecord.testsuite.conftest the pooling hooks never
run, so configure_pool_size stays 0 and every xdist worker falls back to the
shared scenario database, racing on schema DDL. Load the plugin and guard the
backend's own --scenarios option so both conftests coexist.

* fix(test): apply pooled database names in backend and connection feature conftests

* fix(test): apply pooled database names in worker connection params

* fix(test): check for simultaneous double-hold instead of id uniqueness

* fix(test): use a non-empty LSN range for pg_get_wal_records_info

* feat: CLI async unification, --ssl param; postgres backend fixes

* feat(postgres): add named expression/procedure example modules

- Add named_expressions order_expressions (import-safe, prepare_orders_demo helper)
- Add named_procedures order_workflow (OrderProcessingProcedure, max_concurrency=1
  for psycopg single-connection concurrency limit)
- Update bash scripts to reference real module paths instead of placeholders
  and full module paths for --list (package path returns no entries)

* test(expression): add serialization round-trip coverage for PostgreSQL expressions

* fix(dialect): translate is_auto_increment to GENERATED BY DEFAULT AS IDENTITY

ColumnConstraint(is_auto_increment=True) on PRIMARY_KEY was silently ignored,
producing INTEGER PRIMARY KEY without auto-increment. PostgreSQL requires
explicit GENERATED BY DEFAULT AS IDENTITY for auto-increment columns.
The existing dialect_options['identity'] path is unaffected.

* test: add is_auto_increment/DDL regression tests

Dialect-level tests (no DB needed) verifying:
1. is_auto_increment=True produces correct auto-increment DDL keyword
2. All standard types (Integer/Text/Boolean/VarChar/Timestamp) compile
3. BooleanType + DEFAULT True is accepted
4. TimestampType maps to correct backend-specific type

Prevents recurrence of bugs found in rbac cross-backend testing.

* fix(config): declare missing autocommit field on PostgresConnectionConfig

The backend read config.autocommit (requires_manual_commit and the
auto-commit handlers in sync/async backends) to decide whether an
explicit COMMIT is needed outside managed transactions, but the field
did not exist on the dataclass, so passing autocommit=True raised a
TypeError and the option was effectively dead. All other backends
(mysql, sqlserver, clickhouse, snowflake, firebird) already declare it.

Replace the defensive getattr() fallbacks with direct attribute access
and add unit tests covering the default value, explicit assignment,
conninfo exclusion, and requires_manual_commit() for both backends.

* test: cover column qualifier resolution under JOINs

Regression tests for qualifier generation vs FROM context: plain field
accessors, mixed/partial aliases, prebuilt-predicate reuse across
contexts, explicit-alias joins, and an xfail sentinel documenting the
accepted dynamic __table_name__ drift limitation. Companion to the
python-activerecord fix that stops forcing table-name aliases on JOIN
ranges.

* test: cover dynamic table/schema names as supported usage

Replace the R4 xfail sentinel with positive tests for the documented
contract: after changing __table_name__ / __schema_name__, expressions
built through field proxies pick up the new identity, and full DQL stays
consistent across FROM / WHERE / SELECT. Seed an archive table and a
second tenant-style schema so both switch directions assert real data.

* feat(test): provide cross-schema fixtures for testsuite

Implements the optional setup_schema_fixtures capability: provisions
ar_crm / ar_shop schemas with customers and orders tables (sync + async
variants; DDL runs through a short-lived sync connection for async),
tracks created schemas, and drops them in cleanup_after_test. Declares
supports_schema() == True.

* feat(dialect): declare supports_schema capability and schema DDL tests

* fix(protocols): declare supports_schema and supports_schema_authorization in PostgresSchemaSupport

* test(provider): provision mixed default/non-default schema fixtures

* test(adapters): offline adapter round-trip coverage for all types

* docs: record stateflow cross-backend test issues (JSON/bool/RETURNING)

* fix(hstore): pass raw % operator to format_binary_operator to avoid double escaping

hstore_to_array_operator passed the already-escaped '%%' operator to
format_binary_operator, which escapes '%' again to '%%%%' (psycopg folds
to '%%' instead of the expected '%'). Pass the raw '%' so
format_binary_operator performs the single %->%% escape as the sole
collection point.

* fix(adapters): parse array literals on read for list fields in TEXT columns

PostgresListAdapter now parses JSON and PostgreSQL array literals via psycopg's
array loader when reading list fields stored in TEXT columns, fixing the
cross-backend round-trip exposed by stateflow tests.

* test: add format_binary_operator % escaping and hstore operator tests

* ci: update testsuite branch to release/v1.0.0.dev17

* ci: update rhosocial-activerecord branch to release/v1.0.0.dev30

* ci: update testsuite branch to release/v1.0.0.dev17

* feat(postgres): add pgvector vector_search function and expression type support

- Add vector_search.py function module with pgvector search capabilities
- Extend expression types with pgvector-related serialization
- Add data_type_formatting mixin improvements
- Add vector search and example compile test coverage

* test: add targeted coverage for low-coverage patch areas

- extend PostgresListAdapter string parsing tests (JSON + PG array literal)
- add HALFVEC/SPARSEVEC DDL format/parse and eq/hash coverage
- cover vector_search edge cases (ip similarity, index options, invalid metric)
- add _get_default_schema config-aware resolution tests for both introspection stacks
- cover backend autocommit handler branches (sync + async, True/False)
- add CLI --ssl mapping and --async flag tests
- add CLI blackbox tests for introspect/status --async

fix(cli): correct async introspect method names (remove _async suffix)

The _handle_introspect_async path called nonexistent list_tables_async,
list_views_async etc. Async introspector methods use the same names as
sync (no _async suffix). Fixes broken async introspect branch.

* fix(test): tolerate empty table list in introspect blackbox tests

CI runs against a fresh test_db where 'introspect tables' returns [],
so assert json.loads(out) (truthy) fails. Assert the parsed JSON is a
list instead, which holds whether or not tables exist.

* chore: add changelog fragment for PR #55

* docs: remove non-standard changelog fragment

The file name stateflow-cross-backend-issues.fixed.md does not follow
the <issue_number>.<type>.md convention. Its content was already
merged into the relevant fix commit.
… format_method

- Backend types carry postgres_-prefixed generic names; dispatch by
  naming convention (format_data_type_<name>); @DDLTypeMixin.handles
  registration removed.
- Formatting functions take (self, expr); the ::type cast syntax is the
  CastExpression formatter.
- Ownership of the expression source tree moves to the core library.
- CI installs rhosocial-activerecord and the testsuite from their active
  branches.
…format_grouping_clause

- Updated imports and usage in recursive_cte_graph_traversal.py (src + tests)
- Updated import in test_property_graph_query_scenarios.py
- Updated protocol conformance exclusion string in test_postgres_protocol_conformance.py
…ion contracts

- 5 type classes declare dialect_options explicitly; unified _type_params
  based equality/hash (hand-written eq/hash retired)
- PostgresEnumType remains BaseExpression (DDL expression, not DataType);
  format_data_type_postgres_enum/supports pair added for future DataType
  subclasses
- 70+ supports_data_type_* added (1:1 with format family);
  supports_data_types() updated to check supports() before including types
- suggested_data_types() returns empty dict (PG handles all core types
  natively; no honest cross-backend suggestion warranted)
- Precision validation: decimal 1-1000/0-precision, float 1-53,
  fractional-seconds 0-6 for time/timestamp types
- parse_type() constructor calls converted to keyword arguments for
  dialect-first signatures; PostgresArrayType/CustomType calls fixed
- New test_postgres_type_protocol.py (24 tests)
- ArrayType(IntegerType(...), dialect=...) → ArrayType(element_type=..., dialect=...)
- DecimalType(10, 2, dialect=...) → DecimalType(precision=10, scale=2, dialect=...)
- TimestampType(6, dialect=...) → TimestampType(fsp=6, dialect=...)
- Hash tests updated: hash(X) == hash(X._type_params())
…ataType convention

Update ColumnDefinition and DataType subclass constructors to use
dialect-first signatures throughout examples:
- ColumnDefinition(dialect, name, type, ...)
- PostgresSerialType(dialect), ArrayType(dialect, ...), IntegerType(dialect), etc.

Aligns with parameter-inline refactor in core library.
- Complete POSTGRES_PROTOCOLS base list with 5 previously-omitted generic
  protocols (AlterTableModifierSupport, DDLTypeSupport, GraphTableSupport,
  ILIKESupport, TriggerSupport).
- Add POSTGRES_NOT_IMPLEMENTED (intentional: generic FunctionSupport
  [Postgres uses PostgresRoutineSupport]; known gaps: AutoIncrementSupport,
  GeneratedColumnSupport — see TODO comments).
- Add negative isinstance test + partition completeness test.
- Whitelist AlterTableModifierSupport/PostgresConstraintSupport and
  ILIKESupport/PostgresILIKESupport overlaps.
Postgres supports SERIAL/IDENTITY and (12+) STORED generated columns but
never declared the generic protocols. Add the missing methods and promote
both protocols from POSTGRES_NOT_IMPLEMENTED to the positive list.
…ion-based signature

Core protocol changed from scatter args to (self, expr). Update backend
overrides and tests to construct expression objects.
- Add backend reserved words and wire format_identifier(need_quote=...)
  through SQLDialectBase, warning when a reserved word is left unquoted
- Rename supports_table_like_syntax to supports_create_table_like
- Add identifier quoting tests
Delete format_identifier, format_commit/rollback_transaction,
format_savepoint/release_savepoint, format_drop_view_statement,
format_drop_materialized_view_statement, supports_generated_columns,
format_truncate_statement, format_refresh_materialized_view_statement,
format_explain_statement — all equivalent to implementations provided
by SQLDialectBase, TransactionControlMixin, ViewMixin, TruncateMixin,
PostgresFeaturesMixin, and ExplainMixin respectively.

dialect.py: 1877 → 1866 (-11)
The dialect methods were removed without moving the behavior into
PostgresExplainMixin/PostgresTruncateMixin, so the generic core
formatters won: EXPLAIN options rendered invalid SQL (COSTS/FORMAT) and
TRUNCATE ignored the 8.4 restart-identity gate. Restore both.
The reverse-coverage conformance test requires the mixin formatters to be
declared on PostgresExplainSupport/PostgresTruncateSupport.
Move 30 methods from dialect.py into 17 mixin files:
- datetime.py, collation.py, dql.py, json.py, generated_column.py,
  expression.py, function.py (new)
- Extended: ilike.py, upsert.py, view.py, materialized_view.py,
  ddl/column.py, ddl/index.py, table.py, ddl/constraint.py,
  dml/locking.py, transaction.py

dialect.py: 1657 → 645 lines (retains __init__, _validate_data_type,
get_parameter_placeholder, get_server_version, create_schema_differ).
…ange expressions

- Add ILikeExpression for format_ilike_expression
- Add EnumTypeNameExpression, EnumValuesExpression
- Add CreateEnumTypeRawExpression, DropEnumTypeRawExpression, AlterEnumAddValueRawExpression
- Add CreateMultirangeTypeStatementExpression, MultirangeAggFunctionExpression
- Update format methods to accept expressions
- Add 16 new tests
@sonarqubecloud

Copy link
Copy Markdown

@vistart

vistart commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author

Closing - will reopen with correct changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant