From 8677ce5857581da206390a668947246b7f33e966 Mon Sep 17 00:00:00 2001 From: Joby Elliott Date: Tue, 25 Sep 2018 11:07:14 -0600 Subject: [PATCH] pick whether virtual columns are persistent or virtual based on primary --- src/Drivers/MySQLDriver.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Drivers/MySQLDriver.php b/src/Drivers/MySQLDriver.php index c40ccf1..e7f7401 100644 --- a/src/Drivers/MySQLDriver.php +++ b/src/Drivers/MySQLDriver.php @@ -52,7 +52,13 @@ class MySQLDriver extends AbstractDriver $lines = []; $lines[] = "`json_data` JSON DEFAULT NULL"; foreach ($args['virtualColumns'] as $path => $col) { - $lines[] = "`{$col['name']}` {$col['type']} GENERATED ALWAYS AS (".$this->expandPath($path).") VIRTUAL"; + $line = "`{$col['name']}` {$col['type']} GENERATED ALWAYS AS (".$this->expandPath($path).")"; + if (@$col['primary']) { + $line .= ' PERSISTENT'; + } else { + $line .= ' VIRTUAL'; + } + $lines[] = $line; } foreach ($args['virtualColumns'] as $path => $col) { if (@$col['primary']) {