Skip to content

Conversation

@MaceWindu
Copy link
Contributor

@MaceWindu MaceWindu commented Feb 28, 2023

Fixes #1024
Fixes #3154

This PR reviews database providing versioning implementation:

  • updates API to register database provider in options to use same set of methods for each provider. Old implementation had non-uniform set of registration methods for each database, often even with different names for same database provider. In new implementation each provider will have 4 overloads to register provider (except SQL CE provider, which doesn't have two last methods as it doesn't have versioning):

    • Use<DB>(optionSetter)
    • Use<DB>(connectionString, optionSetter)
    • Use<DB>(dialect and/or provider, optionSetter = null)
    • Use<DB>(dialect and/or provider, connectionString, optionSetter = )
  • major cleanup of <DB>Tools classes and related code:

    • removed obsoleted BulkCopy APIs
    • removed obsoleted settings
    • moved provider detection logic to corresponding ProviderDetector classes where it wasn't done befor
    • exposed AutoDetect option property for provider detector
    • provider factories (IDataProviderFactory) were updated to support new versioning options like dialect and provider assembly (assemblyName, version attributes). (I wonder if anyone uses those factories at all)
    • unify GetDataProvider API to accept provider and dialect (where applicable) and connection string parameters
    • unify CreateDataConnection API to be 3 methods with
      • connection string/connection/transaction as first parameter
      • provider and dialect as other parameters where applicable
  • added dialect/provider versioning to providers missing it:

    • all provider and dialect enums have AutoDetect value as first entry to use provider/dialect detection logic (still we recommend to specify them explicitly to not depend on it if you don't need to work in unknown environment)
    • Access: add AccessProvider provider selection enum
    • Firebird: add FirebirdVersion dialect selection enum
    • Informix: add InformixProvider provider selection enum
    • MySql/MariaDB: add MySqlProvider provider and MySqlVersion dialect selection enums
    • SQLite: add SQLiteProvider provider selection enum
    • SAP HANA: add SapHanaProvider provider selection enum
    • SAP/Sybase ASE: add SybaseProvider provider selection enum
  • database connection creation logic moved from database provider to database provider adapter interface (IDynamicProviderAdapter)

  • fixed issue with database dialect detection when options specify connection or transaction but not connection string

  • simplify struct types registration in mapping schema: now nullable type will be registered automatically when you register struct type, so there is no need to define two same mappings anymore. Apllicable to AddScalarType and SetDataType methods.

  • adds dialects support for Firebird. Instead of old implementation with generated SQL compatible with Firebird 2.5 now we support 4 dialects: 2.5, 3.0, 4.0 and 5.0

    • v3+: bool now maps to BOOLEAN type by default. To use old mapping to 1/0 chars, specify DataType.Char type hint for your mappings or use 2.5 dialect
    • v3+: switched to OFFSET/FETCH clauses
    • v4+: enabled LATERAL joins
    • v3+: increased batch size for bulk copy queries from 64Kb as query size to 10Mb
    • v5+: increased supported elements limit in IN predicate from 1 500 to 65 535 items
    • v5+: enable support for WHEN NOT MATCHED BY SOURCE merge operations
    • v5+: enable support for quarter qualifier for DatePart functions
    • more dialect-specific changes will be added later by separate PR
  • adds dialects support for MySQL/MariaDB. Instead of old implementation compatible with MySQL 5.5, now we have support for 4 dialects: MySQL 5.7, MySQL 8.0 and MariaDB 10

    • MySQL 8.0/MariaDB: don't use FROM DUAL for table-less queries anymore (still needed for MySQL 5.7 table-less queries with filter)
    • MySQL 8.0/MariaDB: enabled support for CAST to FLOAT/DOUBLE types
    • MySQL 8.0: enabled LATERAL joins
    • MySQL 8.0/MariaDB: enabled native support for EXCEPT/INTERSECT ALL/DISTINCT set operators
    • All: remove generation of FLOAT(N) type. Use DbType property in your mappings if you still need it for some reason
    • more dialect-specific changes will be added later by separate PR
  • enabled LATERAL joins support for SAP HANA

For developers:

  • Firebird 5 added to testing
  • you will need to update your test configuration configs to use new test provider names for MySQL and Firebird:
    • MySql.5.7: MySQL 5.7 using MySql.Data provider
    • MySqlConnector.5.7: MySQL 5.7 using MySqlConnector provider
    • MySql.8.0: MySQL 8.0 using MySql.Data provider
    • MySqlConnector.8.0: MySQL 8.0 using MySqlConnector provider
    • MariaDB.11: MariaDB 11 using MySqlConnector provider. Note that currently MariaDB 11 doesn't differ from 10 in SQL features, so we don't add separate MariaDB 11 dialect.
  • Firebird.2.5
  • Firebird.3
  • Firebird.4
  • Firebird.5
  • we don't test MySQL 5.5 anymore and bumped lowest supported version to 5.7. This also helped to discover some tests incorrectly labeled as 5.7+ compatible while being working only with MySQL 8.0
  • year(2) pre-mysql 5.7 legacy type removed from testing

Known issues (introduced or discovered by PR):

  • Firebird 2.5 bool to char mapping still configured in FirebirdProvider.SetParameter method instead of MappingSchema due to a lot discovered bugs with DataParameter-based mappings. Will be re-enabled and fixed in new parser branch
  • SAP HANA lateral sub-queries with parameters doesn't work as we need to convert parameters to constants (SAP HANA limitation). Will be done in new parser branch
  • Some SAP HANA queries are broken after LATERAL joins were enabled (bad optimizer?). Should be already fixed in new parser branch
  • EXCEPT/INTERSECT ALL set operators emulation for unsupporting databases doesn't handle duplicate records. Will be fixed in new parser/separate PR
  • Some firebird tests generate CROSS APPLY for Firebird 5 after LATERAL joins enabled. Should be already fixed in new parser branch
@MaceWindu MaceWindu added this to the 5.1.0 milestone Feb 28, 2023
@MaceWindu MaceWindu force-pushed the issue/configuration-overloads-fix branch from 8aceffe to 256d4e2 Compare March 6, 2023 09:04
@MaceWindu MaceWindu modified the milestones: 5.1.0, 6.0.0 Mar 6, 2023
@MaceWindu MaceWindu changed the title Fix mess with provider configuration extensions Refactor provider configuration and detection Mar 6, 2023
@MaceWindu MaceWindu force-pushed the issue/configuration-overloads-fix branch from 256d4e2 to 2f422ee Compare April 13, 2024 12:02
- add provider detector to most of providers
@MaceWindu MaceWindu force-pushed the issue/configuration-overloads-fix branch from 2f422ee to c609db9 Compare April 13, 2024 13:57
@MaceWindu MaceWindu changed the base branch from master to version_6 April 13, 2024 13:59
- add Firebird 5 support
- refactor provider adapters - mapping schema fixes - mysql/firebird refactorings fixes - enable FB3+ features
@MaceWindu
Copy link
Contributor Author

/azp run test-all

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).
@MaceWindu
Copy link
Contributor Author

/azp run test-all

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).
@linq2dbot
Copy link

Test baselines changed by this PR. Don't forget to merge/close baselines PR after this pr merged/closed.

@MaceWindu
Copy link
Contributor Author

/azp run test-all

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).
@linq2dbot
Copy link

Test baselines changed by this PR. Don't forget to merge/close baselines PR after this pr merged/closed.

@linq2dbot
Copy link

Test baselines changed by this PR. Don't forget to merge/close baselines PR after this pr merged/closed.

@MaceWindu MaceWindu changed the title Refactor provider configuration and detection Refactor provider configuration and versioning Apr 18, 2024
@MaceWindu
Copy link
Contributor Author

/azp run test-all

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).
@MaceWindu
Copy link
Contributor Author

/azp run test-all

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).
@MaceWindu
Copy link
Contributor Author

/azp run test-all

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).
@MaceWindu
Copy link
Contributor Author

/azp run test-all

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).
@MaceWindu
Copy link
Contributor Author

MaceWindu commented Apr 18, 2024

baselines good, except one sqlite test and missing FB features (all fixed) and several bad queries generated for sap hana after lateral enabled (will be fixed in parser branch, but we really need to add asserts to those tests ) actually all good

sdanyliv
sdanyliv previously approved these changes Apr 18, 2024
viceroypenguin
viceroypenguin previously approved these changes Apr 18, 2024
@MaceWindu MaceWindu dismissed stale reviews from viceroypenguin and sdanyliv via 5272f27 April 18, 2024 13:13
@MaceWindu
Copy link
Contributor Author

/azp run test-all

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).
@MaceWindu MaceWindu merged commit 4704ace into version_6 Apr 18, 2024
@MaceWindu MaceWindu deleted the issue/configuration-overloads-fix branch April 18, 2024 17:50
MaceWindu pushed a commit to linq2db/linq2db.baselines that referenced this pull request Apr 18, 2024
* [Windows / SQLite (specialized tests)] baselines * [Windows / SQLite (both providers)] baselines * [Windows / SQL CE] baselines * [Windows / Access MDB (Jet/ODBC)] baselines * [Windows / SQLite (both providers)] baselines * [Windows / SQL Server 2019] baselines * [Windows / SQL Server 2008] baselines * [Windows / SQL Server 2019] baselines * [Linux / Firebird 2.5] baselines * [Windows / SQL Server EXTRAS] baselines * [Windows / SQL Server 2014] baselines * [Windows / SQL Server 2012] baselines * [Windows / SQL Server 2016] baselines * [Linux / DB2 LUW 11.5] baselines * [Windows / SQL Server 2017] baselines * [Linux / Informix 14.10] baselines * [Linux / Firebird 3.0] baselines * [Linux / MariaDB 11] baselines * [Linux / Firebird 5.0] baselines * [Linux / Firebird 4.0] baselines * [Linux / MySQL 8 (both providers)] baselines * [Linux / MySQL 5.7 (both providers)] baselines * [Linux / Oracle 11g XE] baselines * [Linux / PostgreSQL 11] baselines * [Linux / PostgreSQL 12] baselines * [Windows / SQL Server 2022] baselines * [Linux / PostgreSQL 13] baselines * [Linux / PostgreSQL 14] baselines * [Linux / Oracle 12c] baselines * [Linux / Oracle 18c] baselines * [Linux / PostgreSQL 15] baselines * [Linux / PostgreSQL 16] baselines * [Linux / Oracle 19c] baselines * [Linux / Oracle 23c] baselines * [Linux / Oracle 21c] baselines * [Linux / SQLite (specialized tests)] baselines * [Linux / SQLite (both providers)] baselines * [Linux / Sybase ASE 16] baselines * [Linux / SQL Server EXTRAS] baselines * [Linux / SQL Server 2019] baselines * [Linux / SQL Server 2019] baselines * [Linux / SAP HANA 2] baselines * [Windows / SQL Server 2005] baselines * [Windows / SQLite (specialized tests)] baselines * [Windows / SQLite (both providers)] baselines * [Windows / SQL Server 2019] baselines * [Windows / SQLite (specialized tests)] baselines * [Windows / SQLite (both providers)] baselines * [Windows / SQL Server 2019] baselines * [Windows / SQL Server EXTRAS] baselines * [Linux / Firebird 5.0] baselines * [Linux / Firebird 4.0] baselines * [Linux / Oracle 11g XE] baselines * [Linux / SQL Server EXTRAS] baselines * [Linux / SQL Server 2019] baselines * [Linux / SQL Server 2019] baselines --------- Co-authored-by: Azure Pipelines Bot <azp@linq2db.com>
@MaceWindu MaceWindu modified the milestones: 6.0.0, 6.0.0-preview.1 Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

5 participants