Skip to content

Comments

v1.9.25 - Feature: dialect.foreignKeyCreatesImplicitIndex#140

Merged
gmpassos merged 6 commits intomasterfrom
feature/dialect.foreignKeyCreatesImplicitIndex
Jan 30, 2026
Merged

v1.9.25 - Feature: dialect.foreignKeyCreatesImplicitIndex#140
gmpassos merged 6 commits intomasterfrom
feature/dialect.foreignKeyCreatesImplicitIndex

Conversation

@gmpassos
Copy link
Contributor

  • TableFieldReference:

    • Added nullable field indexName to represent the name of the index if one exists.
  • Added new class TableRelationshipReferenceEntityTyped extending TableRelationshipReference:

    • Adds sourceFieldEntityType and targetFieldEntityType fields of type TypeInfo.
    • Provides copyWithEntityTypes method to create typed copies.
  • TableRelationshipReference:

    • Added nullable fields sourceRelationshipFieldIndex and targetRelationshipFieldIndex.
    • Added copyWithEntityTypes method returning TableRelationshipReferenceEntityTyped.
  • EntityHandler:

    • Added getFieldsListEntityTypes method to return a map of fields that are list entities or references with their TypeInfo.
  • SQLDialect:

    • Added foreignKeyCreatesImplicitIndex boolean flag with default true.
  • DBPostgreSQLAdapter:

    • Added foreignKeyCreatesImplicitIndex flag to PostgreSQL dialect set to false.
    • Updated _findAllTableFieldsReferences query to include foreign key index name (fk_index_name) by joining with pg_index and pg_class.
    • Populated indexName in TableFieldReference instances from query result.
    • Updated relationship references to include sourceRelationshipFieldIndex and targetRelationshipFieldIndex from indexName.
  • DBSQLAdapter:

    • Added detection of missing foreign key indexes when dialect does not create implicit indexes.
    • Added detection of missing relationship reference indexes for collection reference fields.
    • Updated error reporting and logging to include missing reference indexes and relationship reference indexes.
    • Updated _checkDBTableSchemeReferenceField to return TableRelationshipReferenceEntityTyped with entity types.
    • Added generation of missing reference indexes and missing relationship reference indexes SQL statements.
    • Updated _DBTableCheck class:
      • Added fields missingReferenceIndexes and missingRelationshipReferenceIndexes.
      • Added methods to generate missing reference indexes and relationship reference indexes SQL.
    • Added _DBRelationshipTableColumn subclass of _DBTableColumn to represent relationship table columns with relationship table name.
    • Updated SQL generation to create indexes for foreign keys if dialect does not create implicit indexes:
      • Added index creation after foreign key constraints in generateAddColumnAlterTableSQL.
      • Added index creation for relationship table foreign keys in relationship table creation SQL.
  • Dependency updates:

    • async_extension: ^1.2.19 → ^1.2.20
    • meta: ^1.18.0 → ^1.18.1

- `TableFieldReference`:
  - Added nullable field `indexName` to represent the name of the index if one exists.

- Added new class `TableRelationshipReferenceEntityTyped` extending `TableRelationshipReference`:
  - Adds `sourceFieldEntityType` and `targetFieldEntityType` fields of type `TypeInfo`.
  - Provides `copyWithEntityTypes` method to create typed copies.

- `TableRelationshipReference`:
  - Added nullable fields `sourceRelationshipFieldIndex` and `targetRelationshipFieldIndex`.
  - Added `copyWithEntityTypes` method returning `TableRelationshipReferenceEntityTyped`.

- `EntityHandler`:
  - Added `getFieldsListEntityTypes` method to return a map of fields that are list entities or references with their `TypeInfo`.

- `SQLDialect`:
  - Added `foreignKeyCreatesImplicitIndex` boolean flag with default `true`.

- `DBPostgreSQLAdapter`:
  - Added `foreignKeyCreatesImplicitIndex` flag to PostgreSQL dialect set to `false`.
  - Updated `_findAllTableFieldsReferences` query to include foreign key index name (`fk_index_name`) by joining with `pg_index` and `pg_class`.
  - Populated `indexName` in `TableFieldReference` instances from query result.
  - Updated relationship references to include `sourceRelationshipFieldIndex` and `targetRelationshipFieldIndex` from `indexName`.

- `DBSQLAdapter`:
  - Added detection of missing foreign key indexes when dialect does not create implicit indexes.
  - Added detection of missing relationship reference indexes for collection reference fields.
  - Updated error reporting and logging to include missing reference indexes and relationship reference indexes.
  - Updated `_checkDBTableSchemeReferenceField` to return `TableRelationshipReferenceEntityTyped` with entity types.
  - Added generation of missing reference indexes and missing relationship reference indexes SQL statements.
  - Updated `_DBTableCheck` class:
    - Added fields `missingReferenceIndexes` and `missingRelationshipReferenceIndexes`.
    - Added methods to generate missing reference indexes and relationship reference indexes SQL.
  - Added `_DBRelationshipTableColumn` subclass of `_DBTableColumn` to represent relationship table columns with relationship table name.
  - Updated SQL generation to create indexes for foreign keys if dialect does not create implicit indexes:
    - Added index creation after foreign key constraints in `generateAddColumnAlterTableSQL`.
    - Added index creation for relationship table foreign keys in relationship table creation SQL.

- Dependency updates:
  - `async_extension`: ^1.2.19 → ^1.2.20
  - `meta`: ^1.18.0 → ^1.18.1
@gmpassos gmpassos changed the title v1.9.25 v1.9.25 - Feature: dialect.foreignKeyCreatesImplicitIndex Jan 30, 2026
…om `List<bool>` to a record with named fields `(generateTables, checkTables)`.
…ements in addition to `CREATE` and `ALTER TABLE`.
  - Added field `createIndexIfNotExists` to indicate support for `IF NOT EXISTS` in `CREATE INDEX` (default `true`).

- `CreateIndexSQL`:
  - Updated `buildSQL` method to conditionally include `IF NOT EXISTS` only if dialect supports it.
  - Added field `createIndexIfNotExists` to indicate support for `IF NOT EXISTS` in `CREATE INDEX` (default `true`).

- `CreateIndexSQL`:
  - Updated `buildSQL` method to conditionally include `IF NOT EXISTS` only if dialect supports it.
  - `_populateTablesFromSQLsImpl`: fixed error handling for `CREATE INDEX` statements when the SQL dialect does not support `IF NOT EXISTS`.
    - Now logs a warning and ignores the error instead of throwing.
@codecov
Copy link

codecov bot commented Jan 30, 2026

Codecov Report

❌ Patch coverage is 57.92079% with 85 lines in your changes missing coverage. Please review.
✅ Project coverage is 65.46%. Comparing base (265ebce) to head (2c5a06a).
⚠️ Report is 7 commits behind head on master.

Files with missing lines Patch % Lines
lib/src/bones_api_entity_db_sql.dart 35.34% 75 Missing ⚠️
lib/src/bones_api_condition_encoder.dart 83.33% 5 Missing ⚠️
lib/src/bones_api_sql_builder.dart 82.14% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #140      +/-   ##
==========================================
- Coverage   65.49%   65.46%   -0.03%     
==========================================
  Files          62       62              
  Lines       21000    21164     +164     
==========================================
+ Hits        13754    13856     +102     
- Misses       7246     7308      +62     
Flag Coverage Δ
unittests 65.46% <57.92%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@gmpassos gmpassos merged commit 5b7c470 into master Jan 30, 2026
3 of 5 checks passed
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