1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Staudenmeir\EloquentJsonRelations\Grammars; |
4
|
|
|
|
5
|
|
|
use Illuminate\Database\ConnectionInterface; |
6
|
|
|
use Illuminate\Database\Query\Grammars\SqlServerGrammar as Base; |
7
|
|
|
use RuntimeException; |
8
|
|
|
|
9
|
|
|
class SqlServerGrammar extends Base implements JsonGrammar |
10
|
|
|
{ |
11
|
|
|
/** |
12
|
|
|
* Compile a "JSON array" statement into SQL. |
13
|
|
|
* |
14
|
|
|
* @param string $column |
15
|
|
|
* @return string |
16
|
|
|
*/ |
17
|
25 |
|
public function compileJsonArray($column) |
18
|
|
|
{ |
19
|
25 |
|
return $this->wrap($column); |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Compile a "JSON object" statement into SQL. |
24
|
|
|
* |
25
|
|
|
* @param string $column |
26
|
|
|
* @param int $levels |
27
|
|
|
* @return string |
28
|
|
|
*/ |
29
|
|
|
public function compileJsonObject($column, $levels) |
30
|
|
|
{ |
31
|
|
|
throw new RuntimeException('This database is not supported.'); // @codeCoverageIgnore |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Compile a "JSON value select" statement into SQL. |
36
|
|
|
* |
37
|
|
|
* @param string $column |
38
|
|
|
* @return string |
39
|
|
|
*/ |
40
|
6 |
|
public function compileJsonValueSelect(string $column): string |
41
|
|
|
{ |
42
|
6 |
|
[$field, $path] = $this->wrapJsonFieldAndPath($column); |
43
|
|
|
|
44
|
6 |
|
return "json_query($field$path)"; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Determine whether the database supports the "member of" operator. |
49
|
|
|
* |
50
|
|
|
* @param \Illuminate\Database\ConnectionInterface $connection |
51
|
|
|
* @return bool |
52
|
|
|
*/ |
53
|
40 |
|
public function supportsMemberOf(ConnectionInterface $connection): bool |
54
|
|
|
{ |
55
|
40 |
|
return false; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Compile a "member of" statement into SQL. |
60
|
|
|
* |
61
|
|
|
* @param string $column |
62
|
|
|
* @param string|null $objectKey |
63
|
|
|
* @param mixed $value |
64
|
|
|
* @return string |
65
|
|
|
*/ |
66
|
|
|
public function compileMemberOf(string $column, ?string $objectKey, mixed $value): string |
67
|
|
|
{ |
68
|
|
|
throw new RuntimeException('This database is not supported.'); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* Prepare the bindings for a "member of" statement. |
73
|
|
|
* |
74
|
|
|
* @param mixed $value |
75
|
|
|
* @return array |
76
|
|
|
*/ |
77
|
|
|
public function prepareBindingsForMemberOf(mixed $value): array |
78
|
|
|
{ |
79
|
|
|
throw new RuntimeException('This database is not supported.'); |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
|