-
Notifications
You must be signed in to change notification settings - Fork 26
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 SQL type error #104
base: master
Are you sure you want to change the base?
Fix SQL type error #104
Conversation
Cast int values before save
@@ -35,13 +38,30 @@ public function publish(Batch $batch, $bt, Page $page, $area, BlockValue $value) | |||
} | |||
// Now we import the OTHER records. | |||
if ($b) { | |||
$app = Application::getFacadeApplication(); | |||
/** @var Connection $connection */ | |||
$connection = $app->make(Connection::class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be a hard dependency of this class instead of relying on the service locator? IE:
protected $db;
public function __construct(Connection $db)
{
$this->db = $db;
}
if ($column->getName() === $key) { | ||
if ($column->getType()->getName() === Type::INTEGER) { | ||
if ($column->getNotnull()) { | ||
$value = (int) $value; | ||
} else { | ||
$value = $value === null ? null : (int) $value; | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if ($column->getName() === $key) { | |
if ($column->getType()->getName() === Type::INTEGER) { | |
if ($column->getNotnull()) { | |
$value = (int) $value; | |
} else { | |
$value = $value === null ? null : (int) $value; | |
} | |
} | |
} | |
if ( | |
$column->getName() !== $key || | |
$column->getType()->getName() === Type::INTEGER | |
) { | |
continue; | |
} | |
$value = ($column->getNotNull() || $column !== null) : (int) $value : null; | |
break; |
Using an early return (early continue) is more readable to me here, also worth breaking when the proper column is matched
Done. (BC note: If someone created a custom publisher that uses StandardPublisher as fallback, they must change their code) |
Fixes #102, #57, #47
This PR converts values to integers when the table column type is an integer.
You can test this fix by adding an image slider block with entries with no images selected.