While experimenting with V2016 support, I noticed that this code ...
FiledbFile=File.createTempFile("Jackcess",".accdb");dbFile.deleteOnExit();for(FileFormatfmt:newFileFormat[]{FileFormat.V2010,FileFormat.V2016}){dbFile.delete();DatabaseBuilderdbb=newDatabaseBuilder(dbFile);dbb.setFileFormat(fmt);try(Databasedb=dbb.create()){DataTypedt=DataType.fromSQLType(java.sql.Types.BIGINT);System.out.printf("For a \"%s\" file, java.sql.Types.BIGINT maps to %s%n",fmt.toString(),dt.toString());}}
... produces this output:
For a "V2010 [VERSION_14]" file, java.sql.Types.BIGINT maps to LONG
For a "V2016 [VERSION_16]" file, java.sql.Types.BIGINT maps to LONG
For a V2016 file, shouldn't java.sql.Types.BIGINT map to BIG_INT?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
seriously?! i looked at that code and thought "i'll worry about that when someone complains". i can't believe it came up before i even released 2016 support! ;) the problem is that you need the db format in order to make the right decision, which would require a new version of that method with the appropriate overload (you'll notice that in your test code, you don't actually use the db). i wasn't convinced of the utility of all of that.
Last edit: James Ahlborn 2017-12-31
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
i can't believe it came up before i even released 2016 support! ;)
I was looking at it with an eye toward adding V2016 support to UCanAccess.
(you'll notice that in your test code, you don't actually use the db)
Quite true, but that's the way that UCanAccess currently determines what java.sql.Types.BIGINT "means", so that's what I used for my example. It's never been an issue before (except for possible data overflow if somebody tries to stuff a BIGINT greater than Integer.MAX_VALUE or less than Integer.MIN_VALUE into an Access LONG), but I guess now it's "a thing".
Last edit: Gord Thompson 2017-12-31
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I checked in some changes to trunk to add an optional FileFormat param to fromSQLType and to make the correct decision based on that info. let me know what you think.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Looks good. Certainly more elegant than my rather simplistic suggestion.
Perhaps we could add one more fromSQLType signature so callers can specify FileFormat without having to plug in a length value for fixed-length fields?
I can see that as an exploratory coding exercise, but i would imagine that most real code will be looping through some collection of arbitrary types and converting them. those types will probably include length information as well, right?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
While experimenting with V2016 support, I noticed that this code ...
... produces this output:
For a V2016 file, shouldn't java.sql.Types.BIGINT map to BIG_INT?
seriously?! i looked at that code and thought "i'll worry about that when someone complains". i can't believe it came up before i even released 2016 support! ;) the problem is that you need the db format in order to make the right decision, which would require a new version of that method with the appropriate overload (you'll notice that in your test code, you don't actually use the db). i wasn't convinced of the utility of all of that.
Last edit: James Ahlborn 2017-12-31
I was looking at it with an eye toward adding V2016 support to UCanAccess.
Quite true, but that's the way that UCanAccess currently determines what
java.sql.Types.BIGINT
"means", so that's what I used for my example. It's never been an issue before (except for possible data overflow if somebody tries to stuff a BIGINT greater thanInteger.MAX_VALUE
or less thanInteger.MIN_VALUE
into an Access LONG), but I guess now it's "a thing".Last edit: Gord Thompson 2017-12-31
Might this suffice?
for which I could change the call in my test code to
producing
Last edit: Gord Thompson 2018-01-02
I checked in some changes to trunk to add an optional FileFormat param to fromSQLType and to make the correct decision based on that info. let me know what you think.
Looks good. Certainly more elegant than my rather simplistic suggestion.
Perhaps we could add one more
fromSQLType
signature so callers can specify FileFormat without having to plug in a length value for fixed-length fields?man tough crowd! i thought about that. didn't want to bloat the code. especially since those methods are mirrored in ColumnBuilder.
Not a deal-breaker, just looking to avoid a conversation like this (if Jackcess could talk):
User: I want to know what
java.sql.Types.BIGINT
means for a particular FileFormat.Jackcess: Okay, but you need to provide a
lengthInUnits
.User: Which length? The length of a
java.sql.Types.BIGINT
or the length of what it maps to?Jackcess: It doesn't matter because it will be ignored anyway.
I can see that as an exploratory coding exercise, but i would imagine that most real code will be looping through some collection of arbitrary types and converting them. those types will probably include length information as well, right?
Point taken.