Add docs link, misc format tweaks

This commit is contained in:
2024-07-21 22:02:16 -04:00
parent d8330d828a
commit 0659de3f99
16 changed files with 49 additions and 48 deletions

View File

@@ -64,20 +64,20 @@ class Field
$fieldName = (empty($this->qualifier) ? '' : "$this->qualifier.") . 'data' . match (true) {
!str_contains($this->fieldName, '.') => "->>'$this->fieldName'",
$mode === Mode::PgSQL => "#>>'{" . implode(',', explode('.', $this->fieldName)) . "}'",
$mode === Mode::SQLite => "->>'" . implode("'->>'", explode('.', $this->fieldName)) . "'"
$mode === Mode::SQLite => "->>'" . implode("'->>'", explode('.', $this->fieldName)) . "'",
};
$fieldPath = match ($mode) {
Mode::PgSQL => match (true) {
$this->op === Op::BT => is_numeric($this->value[0]) ? "($fieldName)::numeric" : $fieldName,
is_numeric($this->value) => "($fieldName)::numeric",
default => $fieldName
default => $fieldName,
},
default => $fieldName
default => $fieldName,
};
$criteria = match ($this->op) {
Op::EX, Op::NEX => '',
Op::BT => " {$this->paramName}min AND {$this->paramName}max",
default => " $this->paramName"
default => " $this->paramName",
};
return $fieldPath . ' ' . $this->op->toSQL() . $criteria;
}