Firebird queries do not work with CHAR(x) CHARACTER SET OCTETS type
See original GitHub issueI am trying to store some hex data in a database. There are numerous fields, but for my simple test case let’s look at a MAC_ADDRESS field.
CREATE TABLE FOO (
MAC_ADDRESS CHAR(6) CHARACTER SET OCTETS NOT NULL
);
A human readable MAC is hex formatted - something like “FF:FF:FF:FF:FF:FF”. This can be stored as 6 bytes, each a value of 255. I am storing this data.
No combination of field definitions work for both selecting and insert/update on the table. I’ve tried char[], byte[], string, everything.
In the attached example, I am using a string, however as stated I have tried byte[] and other options. Either selection fails or update/insert fails, or both. Never do they all work. Code.zip
Environment details
linq2db version: 1.8.2
Database Server: Firebird 2.5.2
Database Provider: Firebird .Net Provider 5.9.1.0
Operating system: * Windows 10*
Framework version: .NET Framework 4.5.2
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (3 by maintainers)
Yes. I have a table with the following fields:
As you can see, I store byte values and not human readable values. I handle this using LinqToDb with a class and some type converters. But I have also performed a test against all these fields using the Firebird Provider and I will post all results here.
First off, here’s one of my classes:
To use this, I have some extension methods:
And here are my mappings:
Next, here’s what happens when I use the Firebird .Net provider. I’m current to 5.9.1.0.
I hope this helps some. I will add that I had to add extra mappings for my IP V6 class to convert to and from a GUID, etc.
@cantak have @jack128’s solution solved your issue?
I’v took a closer look in to this case and faced with some problems: firebird client reads such field as string, I tried to insert
ascii_char(50) || ascii_char(100) || ascii_char(150) || ascii_char(200)
and then read it, and there are problems with byte converting.How should I read such data directly (without using linq2db only with Firebird .Net Provider)?