From 20ed5d15112f404d620d639fa77765c8296f34a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ale=C5=A1?= Date: Mon, 8 Apr 2019 08:53:04 +0200 Subject: [PATCH 1/3] Update SqlPreprocessor.php --- src/Database/SqlPreprocessor.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Database/SqlPreprocessor.php b/src/Database/SqlPreprocessor.php index ad3ef7f43..333ed7191 100644 --- a/src/Database/SqlPreprocessor.php +++ b/src/Database/SqlPreprocessor.php @@ -253,6 +253,12 @@ private function formatValue($value, string $mode = null): string } return implode(', ', $vx); + } elseif ($mode === 'as') { + foreach ($value as $k => $v) { + $vx[] = $this->delimite($k) . ' AS ' . $this->delimite($v); + } + return implode(', ', $vx); + } else { throw new Nette\InvalidArgumentException("Unknown placeholder ?$mode."); } From ebdd49bdc94206c29d587b949afbef6661734126 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ale=C5=A1?= Date: Mon, 8 Apr 2019 08:55:19 +0200 Subject: [PATCH 2/3] Update SqlPreprocessor.php --- src/Database/SqlPreprocessor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Database/SqlPreprocessor.php b/src/Database/SqlPreprocessor.php index 333ed7191..c9acc0c03 100644 --- a/src/Database/SqlPreprocessor.php +++ b/src/Database/SqlPreprocessor.php @@ -255,7 +255,7 @@ private function formatValue($value, string $mode = null): string } elseif ($mode === 'as') { foreach ($value as $k => $v) { - $vx[] = $this->delimite($k) . ' AS ' . $this->delimite($v); + $vx[] = $this->delimite($k) . ' AS ' . $v; } return implode(', ', $vx); From 4532d681069d9aa0ee0bee6debbddc2237c62b18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ale=C5=A1?= Date: Mon, 8 Apr 2019 08:57:02 +0200 Subject: [PATCH 3/3] Update SqlPreprocessor.php --- src/Database/SqlPreprocessor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Database/SqlPreprocessor.php b/src/Database/SqlPreprocessor.php index c9acc0c03..40345e8ec 100644 --- a/src/Database/SqlPreprocessor.php +++ b/src/Database/SqlPreprocessor.php @@ -20,7 +20,7 @@ class SqlPreprocessor use Nette\SmartObject; /** @var array */ - private const MODE_LIST = ['and', 'or', 'set', 'values', 'order']; + private const MODE_LIST = ['and', 'or', 'set', 'values', 'order', 'as']; private const ARRAY_MODES = [ 'INSERT' => 'values',