Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding an autoincrement field with Firebird 3.0 #1024

Closed
manolopygithub opened this issue Mar 14, 2024 · 2 comments
Closed

Adding an autoincrement field with Firebird 3.0 #1024

manolopygithub opened this issue Mar 14, 2024 · 2 comments

Comments

@manolopygithub
Copy link

Since Firebird 3.0 it allows define autoincremented field, the sufix to create such fiields is:

"GENERATED BY DEFAULT AS IDENTITY NOT NULL".

Therefore, it is necesary define a variable to do that, and then ask if that variable is True to add that sufix to the definition of the field.

_genFields.txt

@manolopygithub manolopygithub changed the title Adding an $fautoinc_fb variable in function _genFields of adodb-datadict.inc.php file Adding a $fautoinc_fb variable in function _genFields of adodb-datadict.inc.php file Mar 14, 2024
@dregad dregad added enhancement firebird Firebird (Tier 2) labels Mar 21, 2024
@dregad
Copy link
Member

dregad commented Mar 21, 2024

Hello,

As a preliminary remark, instead of attaching a text file with modified code, it would be a lot better to submit a pull request with the patch. It would make reviewing and collaboration as well as eventual merging of changes a lot easier.

Anyway I had a quick look at the modified function in your text file, and unfortunately your approach is not correct and cannot be applied as it is, because database-specific code does not belong in the parent class function ADODB_DataDict::_genFields().

The right way to do this is to adapt the driver-specific data dictionary class, in this case the ADODB2_firebird::_createSuffix() method, where you can leverage the existing $fautoinc parameter to have the function return the correct suffix for autoincrement columns.

One more remark on your patch:

$lines[$fid] = $fname.' '.$ftype.' GENERATED BY DEFAULT AS IDENTITY NOT NULL';

I'm not very familiar with Firebird so maybe this is not an issue, but the documentation states that Identity columns are implicitly NOT NULL. Consequently, it feels unnecessary and possibly wrong to add NOT NULL in the suffix as you did.

@dregad dregad changed the title Adding a $fautoinc_fb variable in function _genFields of adodb-datadict.inc.php file Adding an autoincrement field with Firebird 3.0 Mar 21, 2024
@manolopygithub
Copy link
Author

manolopygithub commented Apr 4, 2024 via email

@dregad dregad closed this as not planned Won't fix, can't repro, duplicate, stale May 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants