Skip to content

Conversation

Copy link

Copilot AI commented Nov 3, 2025

GaussDB queries fail on tables with VARCHAR2/NVARCHAR2 columns (Oracle-compatible types) with InvalidCastException: Reading as 'System.Object' is not supported for fields having DataTypeName 'nvarchar2'.

This pull request adds comprehensive support for the VARCHAR2 and NVARCHAR2 string types throughout the codebase, including type definitions, type mappings and test coverage. Additionally, there are minor improvements to workflow configuration and example code for better usability and clarity.

image

- Added VARCHAR2 and NVARCHAR2 to DataTypeNames
- Mapped VARCHAR2/NVARCHAR2 to varchar in DataTypeName.FromDisplayName
- Added VARCHAR2/NVARCHAR2 to GaussDBDbType mappings
- Updated type resolver factories to handle VARCHAR2/NVARCHAR2
- Updated GaussDBParameter size truncation to support VARCHAR2/NVARCHAR2
- Updated GaussDBSchema to treat VARCHAR2/NVARCHAR2 as String types
- Added test cases for VARCHAR2 and NVARCHAR2

Co-authored-by: WeihanLi <[email protected]>
Copilot AI changed the title [WIP] 使用dotnet驱动查询含有NVARCHAR2类型字段的表报错 Add VARCHAR2/NVARCHAR2 type support for Oracle migration compatibility Nov 3, 2025
Copilot AI requested a review from WeihanLi November 3, 2025 02:44
Copilot finished work on behalf of WeihanLi November 3, 2025 02:44
@WeihanLi
Copy link

WeihanLi commented Nov 3, 2025

@copilot add test cases to create a table with VARCHAR2/NVARCHAR2 columns, and verify new data insert/query supports

- Test creates table with VARCHAR2 and NVARCHAR2 columns
- Tests INSERT operations with various string values
- Tests SELECT/query operations to read the data
- Tests NULL value handling
- Includes proper table cleanup

Co-authored-by: WeihanLi <[email protected]>
Copy link
Author

Copilot AI commented Nov 3, 2025

@copilot add test cases to create a table with VARCHAR2/NVARCHAR2 columns, and verify new data insert/query supports

Added comprehensive test case in commit 3ff54a6 that:

  • Creates a table with VARCHAR2 and NVARCHAR2 columns
  • Tests INSERT operations with various string values
  • Verifies SELECT/query operations read data correctly
  • Tests NULL value handling
  • Includes proper table cleanup

Copilot finished work on behalf of WeihanLi November 3, 2025 05:22
@WeihanLi WeihanLi requested a review from Copilot November 4, 2025 11:39
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for VARCHAR2 and NVARCHAR2 data types to GaussDB, which are Oracle-compatible variable-length string types. These types are treated similarly to the existing VARCHAR and TEXT types.

  • Added new enum values and mappings for VARCHAR2 and NVARCHAR2 types
  • Integrated these types into existing text type handling across resolver factories and parameter handling
  • Added comprehensive test coverage for table operations with both types
  • Updated example code to demonstrate the new types

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/GaussDB/Internal/Postgres/DataTypeNames.cs Added Varchar2 and Nvarchar2 constant definitions
src/GaussDB/GaussDBTypes/GaussDBDbType.cs Added enum values and conversions for Varchar2 and Nvarchar2 types
src/GaussDB/Internal/ResolverFactories/ExtraConversionsTypeInfoResolverFactory.cs Included Varchar2 and Nvarchar2 in alternative text type iterations
src/GaussDB/Internal/ResolverFactories/AdoTypeInfoResolverFactory.cs Included Varchar2 and Nvarchar2 in alternative text type iterations
src/GaussDB/GaussDBSchema.cs Added Varchar2 and Nvarchar2 to hardcoded data type info population
src/GaussDB/GaussDBParameter.cs Added Varchar2 and Nvarchar2 to size truncation handling logic
test/GaussDB.Tests/Types/TextTests.cs Added comprehensive integration test for Varchar2 and Nvarchar2 operations
example/GetStarted/Program.cs Updated example to demonstrate Varchar2 and Nvarchar2 usage
src/GaussDB/GaussDB.csproj Removed CodeAnalysis package reference
Directory.Build.props Bumped version from 0.1.0 to 0.1.1
.github/workflows/test.yml Added comment about connection string and set max-parallel to 1

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@WeihanLi WeihanLi marked this pull request as ready for review November 4, 2025 12:02
Copy link
Collaborator

@JusterZhu JusterZhu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may still need testing.

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.

使用dotnet驱动查询含有NVARCHAR2类型字段的表报错

3 participants