Changes for beta10 (#5)

- Add In/InArray support
- Add ORDER BY support for `Find` functions
- Update dependencies
- Implement fixes identified via static analysis

Reviewed-on: #5
This commit was merged in pull request #5.
This commit is contained in:
2024-09-27 02:15:00 +00:00
parent 9e0e663811
commit d067f8983f
66 changed files with 1728 additions and 664 deletions

View File

@@ -9,28 +9,32 @@ declare(strict_types=1);
namespace BitBadger\PDODocument;
/**
* The types of logical operations allowed for JSON fields
* The types of comparison operators allowed for JSON fields
*/
enum Op
{
/** Equals (=) */
case EQ;
case Equal;
/** Greater Than (>) */
case GT;
case Greater;
/** Greater Than or Equal To (>=) */
case GE;
case GreaterOrEqual;
/** Less Than (<) */
case LT;
case Less;
/** Less Than or Equal To (<=) */
case LE;
case LessOrEqual;
/** Not Equal to (<>) */
case NE;
case NotEqual;
/** Between (BETWEEN) */
case BT;
case Between;
/** In (IN) */
case In;
/** In Array (PostgreSQL - ?|, SQLite - EXISTS / json_each / IN) */
case InArray;
/** Exists (IS NOT NULL) */
case EX;
case Exists;
/** Does Not Exist (IS NULL) */
case NEX;
case NotExists;
/**
* Get the SQL representation of this operator
@@ -40,15 +44,17 @@ enum Op
public function toSQL(): string
{
return match ($this) {
Op::EQ => "=",
Op::GT => ">",
Op::GE => ">=",
Op::LT => "<",
Op::LE => "<=",
Op::NE => "<>",
Op::BT => "BETWEEN",
Op::EX => "IS NOT NULL",
Op::NEX => "IS NULL",
Op::Equal => "=",
Op::Greater => ">",
Op::GreaterOrEqual => ">=",
Op::Less => "<",
Op::LessOrEqual => "<=",
Op::NotEqual => "<>",
Op::Between => "BETWEEN",
Op::In => "IN",
Op::InArray => "??|", // The actual operator is ?|, but needs to be escaped by doubling
Op::Exists => "IS NOT NULL",
Op::NotExists => "IS NULL",
};
}
}