-
-
Notifications
You must be signed in to change notification settings - Fork 38
Fix #888 issue #948
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
base: master
Are you sure you want to change the base?
Fix #888 issue #948
Changes from all commits
804c637
13f23c7
fd253ea
966e214
7a5d737
1e281ab
2514ee0
c43d104
64f818c
219c7c6
23c9235
905efb0
028baf8
e42d4b6
c19ffde
3203b8b
4d6074f
0beb7a2
ad6f4ad
c770c9b
923fd32
43ef361
87ba24c
1828d68
b34c105
d126e1f
020c3f3
f723c72
4b5d89c
3973033
449714d
e267224
4b3bc67
eabb05b
d8979b1
c1bf4f8
a808c98
27a23e3
a8263e9
d9c59e7
1503a92
f44b968
2dd73a0
ead1311
fc6d788
915c3e0
e6be689
ecce7a3
0c933d4
ff0e7af
0064ea4
133ea38
082d055
f4fff70
4be947f
3d1b474
221543c
7a54d2f
22a1906
7115b06
951c0f7
87ff7b5
48df33f
281f2ae
bbe1e43
703ca43
f58ce6f
a684cc0
4139d81
9e3507c
5d43b04
32d8d7e
6100168
b48e8e2
31a09b4
a3202bd
4eed6d3
b1ec11e
fdf3066
05e72b0
aa8ef79
0fcdee0
0d57a8c
5a576f6
1dc6825
05ad7a7
08e1b72
2736a60
1bb5b2e
7189f0c
fdc5f2e
bb6a9ba
041c42b
1e0cd08
a1237d4
4fb566e
ec45d61
6f37004
f95ba39
c1bd00a
3d63c51
38120ed
ac2034d
e6e25f1
a12d48d
42d4b5e
9e2d1f4
f2a9044
6d328ea
fe97ad0
8685919
e49b146
ae82c6c
efb1b87
f833773
2494cb8
547ce2d
309cf28
acd8224
390bd69
1828754
59e92f3
5bc377e
937a491
8d233d7
5bacb06
597661f
ab396bf
fdaffb7
088adda
44165b8
6cc0a89
fc4c5d6
fc0e269
2a87ca6
611ed45
2df28c2
1a09db6
08c39f2
91ffdf6
c518a0d
f11ee5c
a4dc56a
ec50b75
ab3f9a3
78cb71d
4e855e9
adaa1fe
0a3157c
2b6b25f
7905ed7
b41aa4c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,44 @@ | ||||||||||||
<?php | ||||||||||||
|
||||||||||||
declare(strict_types=1); | ||||||||||||
|
||||||||||||
namespace Yiisoft\Db\Command; | ||||||||||||
|
||||||||||||
use Yiisoft\Db\Exception\Exception; | ||||||||||||
|
||||||||||||
/** | ||||||||||||
* Object used as batch commands container | ||||||||||||
*/ | ||||||||||||
final class BatchCommand | ||||||||||||
{ | ||||||||||||
/** | ||||||||||||
* @param CommandInterface[] $commands Query statements for execution | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
*/ | ||||||||||||
public function __construct(private readonly array $commands) | ||||||||||||
{ | ||||||||||||
} | ||||||||||||
|
||||||||||||
public function count(): int | ||||||||||||
{ | ||||||||||||
return count($this->commands); | ||||||||||||
} | ||||||||||||
Comment on lines
+20
to
+24
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Looks redundant. |
||||||||||||
|
||||||||||||
public function getCommands(): array | ||||||||||||
{ | ||||||||||||
return $this->commands; | ||||||||||||
} | ||||||||||||
|
||||||||||||
/** | ||||||||||||
* @throws \Throwable | ||||||||||||
* @throws Exception | ||||||||||||
*/ | ||||||||||||
public function execute(): int | ||||||||||||
{ | ||||||||||||
$total = 0; | ||||||||||||
foreach ($this->commands as $command) { | ||||||||||||
$total += $command->execute(); | ||||||||||||
} | ||||||||||||
|
||||||||||||
return $total; | ||||||||||||
} | ||||||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Yiisoft\Db\Command; | ||
|
||
/** | ||
* Represents an SQL statement used for batch commands execution. | ||
*/ | ||
class QueryStatement | ||
{ | ||
/** | ||
* @param string $sql SQL query. | ||
* @param array $params Parameters for query execution. | ||
*/ | ||
public function __construct(public string $sql, public array $params = []) | ||
{ | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -117,4 +117,13 @@ protected function rollbackTransactionOnLevel(TransactionInterface $transaction, | |
} | ||
} | ||
} | ||
|
||
public function getParametersLimit(): int | ||
{ | ||
// Must be overridden in a DBMS package which has a limit | ||
if ($this->getDriverName() === 'pgsql') { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should it be moved to PostgreSQL package? |
||
return 65535; | ||
} | ||
return 0; | ||
} | ||
} |
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.