From 1ff5c35de5dbd70a782875a91dd2232fd01b002b Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 14:38:04 +0200 Subject: Adding upstream version 0.10.1. Signed-off-by: Daniel Baumann --- vendor/ipl/orm/src/Behavior/Binary.php | 116 +++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 vendor/ipl/orm/src/Behavior/Binary.php (limited to 'vendor/ipl/orm/src/Behavior/Binary.php') diff --git a/vendor/ipl/orm/src/Behavior/Binary.php b/vendor/ipl/orm/src/Behavior/Binary.php new file mode 100644 index 0000000..98a4bf4 --- /dev/null +++ b/vendor/ipl/orm/src/Behavior/Binary.php @@ -0,0 +1,116 @@ +rewriteSubjects = $this->properties; + + if (! $query->getDb()->getAdapter() instanceof Pgsql) { + // Only process properties if the adapter is PostgreSQL. + $this->properties = []; + } + } + + public function rewriteCondition(Condition $condition, $relation = null) + { + /** + * TODO(lippserd): Duplicate code because {@see RewriteFilterBehavior}s come after {@see PropertyBehavior}s. + * {@see \ipl\Orm\Compat\FilterProcessor::requireAndResolveFilterColumns()} + */ + $column = $condition->metaData()->get('columnName'); + if (isset($this->rewriteSubjects[$column])) { + $value = $condition->getValue(); + + if (empty($this->properties) && is_resource($value)) { + // Only for PostgreSQL. + throw new UnexpectedValueException(sprintf('Unexpected resource for %s', $column)); + } + + // ctype_xdigit expects strings. + $value = (string) $value; + /** + * Although this code path is also affected by the duplicate behavior evaluation stated in {@see toDb()}, + * no further adjustments are needed as ctype_xdigit returns false for binary and bytea hex strings. + */ + if (ctype_xdigit($value)) { + if (empty($this->properties) && substr($value, 0, 2) !== '\\x') { + // Only for PostgreSQL. + $condition->setValue(sprintf('\\x%s', $value)); + } else { + $condition->setValue(hex2bin($value)); + } + } + } + } +} -- cgit v1.2.3