You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm migrating a table from one database to another using Tiberius. The schemas of the source and target tables are almost identical, with the only difference being that the source table has an IDENTITY column (ID), while the target table has an INT column.
I have a date conversion function that converts a tiberius::time::time::Date to a tiberius::time::Date. The conversion seems to work fine, as I don't encounter any errors when pushing the data into the TokenRow. However, when I execute the following line:
let res = req.finalize().await?;
info!("######## TOTAL: {}", res.total());
I get the following error:
[2025-01-23T18:37:45Z ERROR tiberius::tds::stream::token] Invalid column type from bcp client for colid 18. code=4816
If I remove the Date column from the source table, the error does not occur.
Here is the relevant code for the date conversion:
...
tiberius::ColumnType::Daten => {
let val = row.get::<tiberius::time::time::Date, _>(index);
match val {
Some(originaldate) => {
info!("oooooooooooooo date before: {}", originaldate);
let newdate = convert_date(originaldate);
info!("oooooooooooooo date converted: {:?}", newdate);
ColumnData::Date(Some(newdate))
}
None => ColumnData::Date(None), // Handle NULL values
}
}
...
And the date conversion function:
fn convert_date(olddate: tiberius::time::time::Date) -> tiberius::time::Date {
// Create a NaiveDate for January 1, year 1
let epoch = NaiveDate::from_ymd_opt(1, 1, 1).expect("Invalid epoch date");
let date = NaiveDate::from_ymd_opt(
olddate.year(),
olddate.month() as u32,
olddate.day() as u32,
).expect("Invalid date");
let days_since_epoch = date.signed_duration_since(epoch).num_days() as u32;
tiberius::time::Date::new(days_since_epoch)
}
Questions:
What could be causing the Invalid column type from bcp client for colid 18 error?
Is there an issue with the date conversion logic that might be causing this error?
Are there any known issues with Tiberius and BCP client compatibility for date columns?
Any help or insights would be greatly appreciated!
The text was updated successfully, but these errors were encountered:
I'm migrating a table from one database to another using Tiberius. The schemas of the source and target tables are almost identical, with the only difference being that the source table has an
IDENTITY
column (ID), while the target table has anINT
column.I have a date conversion function that converts a
tiberius::time::time::Date
to atiberius::time::Date
. The conversion seems to work fine, as I don't encounter any errors when pushing the data into theTokenRow
. However, when I execute the following line:I get the following error:
[2025-01-23T18:37:45Z ERROR tiberius::tds::stream::token] Invalid column type from bcp client for colid 18. code=4816
If I remove the
Date
column from the source table, the error does not occur.Here is the relevant code for the date conversion:
And the date conversion function:
Questions:
Any help or insights would be greatly appreciated!
The text was updated successfully, but these errors were encountered: