Skip to content

Conversation

@lovasoa
Copy link
Collaborator

@lovasoa lovasoa commented Sep 25, 2025

Update decode_column_name to accept Vec<u16> and decode using String::from_utf16 to resolve a type mismatch.


Open in Cursor Open in Web

Co-authored-by: contact <contact@ophir.dev>
@cursor
Copy link

cursor bot commented Sep 25, 2025

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@lovasoa
Copy link
Collaborator Author

lovasoa commented Sep 25, 2025

@cursoragent you broke the linux version that used to work

error[E0308]: mismatched types
   --> sqlx-core/src/odbc/connection/odbc_bridge.rs:136:34
    |
136 |         name: decode_column_name(cd.name, index),
    |               ------------------ ^^^^^^^ expected `Vec<u16>`, found `Vec<u8>`
    |               |
    |               arguments to this function are incorrect
    |
    = note: expected struct `Vec<u16>`
               found struct `Vec<u8>`
note: function defined here
   --> sqlx-core/src/odbc/connection/odbc_bridge.rs:142:4
    |
142 | fn decode_column_name(name_words: Vec<u16>, index: u16) -> String {
    |    ^^^^^^^^^^^^^^^^^^ --------------------

error[E0308]: mismatched types
  --> sqlx-core/src/odbc/connection/mod.rs:37:34
   |
37 |         name: decode_column_name(cd.name, index),
   |               ------------------ ^^^^^^^ expected `Vec<u16>`, found `Vec<u8>`
   |               |
   |               arguments to this function are incorrect
   |
   = note: expected struct `Vec<u16>`
              found struct `Vec<u8>`
note: function defined here
  --> sqlx-core/src/odbc/connection/mod.rs:43:4
   |
43 | fn decode_column_name(name_words: Vec<u16>, index: u16) -> String {
   |    ^^^^^^^^^^^^^^^^^^ --------------------

the code needs to work on BOTH linux and windows

@cursor
Copy link

cursor bot commented Sep 25, 2025

🔄 Received a new followup. Follow along in the new message.


⌛ Working on 3 tasks

  • Make decode_column_name generic to handle Vec/Vec (bridge)
  • Make decode_column_name generic to handle Vec/Vec (mod)
  • Run lints on modified files

Open in Cursor Open in Web

@lovasoa
Copy link
Collaborator Author

lovasoa commented Sep 25, 2025

@cursoragent
https://docs.rs/odbc-api/latest/odbc_api/handles/struct.ColumnDescription.html

odbc_api::handles

Struct ColumnDescription
Source
Search
Settings
Help

pub struct ColumnDescription {
pub name: Vec<SqlChar>,
pub data_type: DataType,
pub nullability: Nullability,
}

Describes the type and attributes of a column.
Fields
§
name: Vec<SqlChar>

Column name. May be empty if unavailable.
data_type: DataType

Type of the column
nullability: Nullability

Indicates whether the column is nullable or not.

#[cfg(not(any(feature = "wide", all(not(feature = "narrow"), target_os = "windows"))))]
pub type SqlChar = u8;
#[cfg(any(feature = "wide", all(not(feature = "narrow"), target_os = "windows")))]
pub type SqlChar = u16;

Co-authored-by: contact <contact@ophir.dev>
@cursor
Copy link

cursor bot commented Sep 25, 2025

  • Implemented a cross-platform fix: decode_column_name now accepts either Vec<u8> or Vec<u16> via a small local trait, matching odbc_api::handles::SqlChar being u8 (Linux/narrow) or u16 (Windows/wide).

  • No call sites changed; both cd.name: Vec<SqlChar> forms now compile.

  • Lints are clean. Please run your build on Linux and Windows to confirm.

  • Files updated:

    • sqlx-core/src/odbc/connection/odbc_bridge.rs
    • sqlx-core/src/odbc/connection/mod.rs

Open in Cursor Open in Web

Learn more about Cursor Agents

@lovasoa
Copy link
Collaborator Author

lovasoa commented Sep 25, 2025

@cursoragent You duplicated code between sqlx-core/src/odbc/connection/mod.rs and sqlx-core/src/odbc/connection/odbc_bridge.rs

Remove code duplication

@cursor
Copy link

cursor bot commented Sep 25, 2025

🔄 Received a new followup. Follow along in the new message.


⌛ Working on 3 tasks

  • Make decode_column_name generic to handle Vec/Vec (bridge)
  • Make decode_column_name generic to handle Vec/Vec (mod)
  • Run lints on modified files

Open in Cursor Open in Web

@lovasoa
Copy link
Collaborator Author

lovasoa commented Sep 25, 2025

@cursoragent and add a very basic ci test that build the library on windows. Very minimal, few lines of code, reuse the existing ci workflow as much as possible

Co-authored-by: contact <contact@ophir.dev>
@cursor
Copy link

cursor bot commented Sep 25, 2025

I enhanced the CI pipeline by implementing a new job to validate sqlx-core builds on Windows with ODBC, improving cross-platform reliability. Additionally, I performed a minor refactoring in the ODBC connection module to streamline internal imports.

  • I added a new windows-build job to .github/workflows/sqlx.yml. This job ensures that sqlx-core successfully compiles on Windows with the odbc, all-types, and runtime-tokio-rustls features enabled, improving build stability for Windows environments.
  • I refactored the import path for decode_column_name in sqlx-core/src/odbc/connection/odbc_bridge.rs from crate::odbc::connection::decode_column_name to super::decode_column_name. This is a minor change to improve module import consistency.
  • I removed a lingering comment THIS SHOULD BE A LINTER ERROR from sqlx-core/src/odbc/connection/odbc_bridge.rs.

2 tasks completed

  • Add minimal Windows build job to sqlx.yml for sqlx-core
  • Run lints/validate workflow syntax after change
    Open in Cursor Open in Web

Learn more about Cursor Agents

@lovasoa
Copy link
Collaborator Author

lovasoa commented Sep 26, 2025

@cursoragent

failures:

---- sqlite::testing::test_convert_path stdout ----

thread 'sqlite::testing::test_convert_path' panicked at sqlx-core\src\sqlite\testing\mod.rs:80:5:
assertion left == right failed
left: "target/sqlx/test-dbs\foo\bar\baz\quux.sqlite"
right: "target/sqlx/test-dbs/foo/bar/baz/quux.sqlite"

failures:
sqlite::testing::test_convert_path

test result: FAILED. 225 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.03s

error: test failed, to rerun pass --lib
Process completed with exit code 1.

@cursor
Copy link

cursor bot commented Sep 26, 2025

I modified the convert_path function within the SQLite testing module to ensure consistent path formatting. This change specifically addresses path separators for improved cross-platform compatibility, particularly for Windows environments.

  • I modified the convert_path function in sqlx-core/src/sqlite/testing/mod.rs.
  • I added a call to .replace('\\', '/') on the final path string. This standardizes path separators by converting Windows-style backslashes to forward slashes, ensuring consistent file paths for SQLite test databases across different operating systems.

Open in Cursor Open in Web

Learn more about Cursor Agents

@lovasoa lovasoa marked this pull request as ready for review September 26, 2025 09:05
@lovasoa lovasoa merged commit 2de0fd2 into main Sep 26, 2025
65 checks passed
@lovasoa lovasoa deleted the cursor/fix-odbc-column-name-type-mismatch-ab07 branch September 26, 2025 09:19
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.

3 participants