diff --git a/src/Driver/Database/sqlsrv/Schema.php b/src/Driver/Database/sqlsrv/Schema.php index 2bbe1e9..76a8dc7 100644 --- a/src/Driver/Database/sqlsrv/Schema.php +++ b/src/Driver/Database/sqlsrv/Schema.php @@ -708,6 +708,37 @@ class Schema extends DatabaseSchema { $this->cacheSchema = $options['cache_schema'] ?? FALSE; } + /** + * {@inheritdoc} + * + * The $this->defaultSchema seems to be not set in drush command context, + * we use $this->getDefaultSchema() instead to make the drush command work + */ + protected function getPrefixInfo($table = 'default', $add_prefix = TRUE) { + $info = [ + 'schema' => $this->getDefaultSchema(), + 'prefix' => $this->connection->tablePrefix($table), + ]; + if ($add_prefix) { + $table = $info['prefix'] . $table; + } + // If the prefix contains a period in it, then that means the prefix also + // contains a schema reference in which case we will change the schema key + // to the value before the period in the prefix. Everything after the dot + // will be prefixed onto the front of the table. + if (($pos = strpos($table, '.')) !== FALSE) { + // Grab everything before the period. + $info['schema'] = substr($table, 0, $pos); + // Grab everything after the dot. + $info['table'] = substr($table, ++$pos); + } else { + $info['table'] = $table; + } + return $info; + } + + + /** * {@inheritdoc} *