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

fix(federation): Allow Oracles empty strings #49750

Merged
merged 1 commit into from
Dec 10, 2024

Conversation

nickvergessen
Copy link
Member

Summary

  • Since this is a general problem I wonder if we should fix it in a better way. Basically we need $this->addType('account', 'string'); to specify if they are "nullable" and if not "heal oracle" by converting null to empty string?

Checklist

Signed-off-by: Joas Schilling <coding@schilljs.com>
@ArtificialOwl
Copy link
Member

  • Since this is a general problem I wonder if we should fix it in a better way. Basically we need $this->addType('account', 'string'); to specify if they are "nullable" and if not "heal oracle" by converting null to empty string?

can we fix this in the QueryBuilder directly and not just at the QBMapper level ?

@nickvergessen
Copy link
Member Author

can we fix this in the QueryBuilder directly and not just at the QBMapper level ?

It's not the query builder but the entity. The problem is when explicit null is allowed, we shouldn't map it to an empty string.
But that is basically the other way a problem. If a field is nullable, we should not allow other databases to return/use empty strings…

@miaulalala
Copy link
Contributor

So IIRC Oracle doesn't have null values in the DB, is that right? If so, I think the entity class in general should compensate for that. The returns should be identical across all supported Database types, and the Entity should abstract that for us.

@nickvergessen
Copy link
Member Author

So IIRC Oracle doesn't have null values in the DB, is that right?

Other way around, empty strings '' are stored as null

@nickvergessen
Copy link
Member Author

Let's merge this for now, so Talk tests are green again and then we can have a look at the general Entity patch later.

@nickvergessen nickvergessen merged commit 28ec9c7 into master Dec 10, 2024
187 of 188 checks passed
@nickvergessen nickvergessen deleted the bugfix/noid/oracle-federation branch December 10, 2024 14:30
@nickvergessen
Copy link
Member Author

nickvergessen commented Dec 11, 2024

@ArtificialOwl after some further checking, you marked the column nullable / notnull => false in the migration:

$table->addColumn('account', Types::STRING, [
'notnull' => false,
'length' => 127,
'default' => ''
]);

So in this case the entity also needs to be able to understand null and the change in this PR is actually required, regardless of any other entity fiddling for empty strings.
If it would be notnull => true the migration service would throw an exception

if ($thing->getNotnull() && $thing->getDefault() === ''
&& $sourceTable instanceof Table && !$sourceTable->hasColumn($thing->getName())) {
throw new \InvalidArgumentException('Column "' . $table->getName() . '"."' . $thing->getName() . '" is NotNull, but has empty string or null as default.');
}

I guess it did and that is when you changed changed the schema, but didn't adjust the entity to also allow null.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants