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
ADODB_DataDict._GenFields: Unconditional remove of nullability and default on blobs #292
Comments
Missed an outstanding pull request pr #118, adressing this issue. Reconsidering my first thougts and the approach taken in the pull request, I would now recommend to handle this in a more general way in the generic datadict. There might be other field types beside blobs with restrictions too. And if we agree on: Any given schema should be me mapped as precisely as possible to the underlying db. then Either we drop those lines completely and let it to the dbs datadict to handle this, implementing its own _GenFields or take care of it in Add/AlterColumnSQL (caveat: to preserve current behaviour all dbs datadicts have to be adjusted, and at least me don't know what all the supported dbs would require then). or a) Extend the generic datadict with something like:
b) Alter the corresponding lines:
c) To preserve current behaviour (and put it to the db to handle) extend all dbs datadicts with:
d) Adjust (c) for the known ones (datadict_?) in the first place [1]: mysql (from pr #118)
postgres (from pr #118)
mssql (me)
If this sounds reasonable to the devs and we could agree on d)+[1] I would volunteer a pull request on this. But given the hassle I have had with the last one (git with me and my dev box 👎 ), only if the path we want to go is set. [1] Correct/Add others. |
@obmsch thank you for your follow-up and proposal to volunteer. Due to my current workload I don't cant look at this into details ATM, will do so as soon as I can (no promises on when). As a side note, if you need any help with Git, feel free to contact me on Gitter at any time though. |
Add 'XL' to the blob checks in _GenFields.
Add 'XL' to the blob checks in _GenFields. See #292
In 'adodb-datadict' inside _GenFields:
line 729
if ($ty == 'X' || $ty == 'X2' || $ty == 'B') $fnotnull = false; // some blob types do not accept nulls [cf #291]
line 733-734
//some databases do not allow blobs to have defaults
if ($ty == 'X') $fdefault = false;
Thats completely ignoring the capabilites of any db to honor some dbs not implementing that feature. I am looking for a better approach(My knowledge of php and its inner workings is really limited. So this is more conceptional than a real implementation).
Add members (for capabilities) to the base class ADODB_DataDict like
$hasNullableBlobs = false;
$hasDefaultOnBlobs = false;
Change the code above to:
if (!$this->hasNullableBlobs && ($ty == 'X' || $ty == 'X2' || $ty == 'B')) $fnotnull = ...
and
if (!$this->hasDefaultOnBlobs && $ty == 'X') $fdefault = false;
Thats a noop in behaviour of ADOdb.
But lets say a db supports NULL in blobs, setting $hasNullableBlobs = true; in its datadict should do the trick.
The text was updated successfully, but these errors were encountered: