@@ -31,6 +31,8 @@ class SQLiteAdapter extends PdoAdapter
3131{
3232 public const MEMORY = ':memory: ' ;
3333
34+ public const DEFAULT_SUFFIX = '.sqlite3 ' ;
35+
3436 /**
3537 * List of supported Phinx column types with their SQL equivalents
3638 * some types have an affinity appended to ensure they do not receive NUMERIC affinity
@@ -121,7 +123,7 @@ class SQLiteAdapter extends PdoAdapter
121123 /**
122124 * @var string
123125 */
124- protected string $ suffix = ' .sqlite3 ' ;
126+ protected string $ suffix = self :: DEFAULT_SUFFIX ;
125127
126128 /**
127129 * Indicates whether the database library version is at least the specified version
@@ -195,21 +197,38 @@ public function connect(): void
195197 }
196198
197199 /**
198- * @inheritDoc
200+ * Get the suffix to use for the SQLite database file.
201+ *
202+ * @param array $options Environment options
203+ * @return string
199204 */
200- public function setOptions (array $ options ): AdapterInterface
205+ public static function getSuffix (array $ options ): string
201206 {
202- parent ::setOptions ($ options );
207+ if ($ options ['name ' ] === self ::MEMORY ) {
208+ return '' ;
209+ }
203210
211+ $ suffix = self ::DEFAULT_SUFFIX ;
204212 if (isset ($ options ['suffix ' ])) {
205- $ this -> suffix = $ options ['suffix ' ];
213+ $ suffix = $ options ['suffix ' ];
206214 }
207215 //don't "fix" the file extension if it is blank, some people
208216 //might want a SQLITE db file with absolutely no extension.
209- if ($ this -> suffix !== '' && strpos ($ this -> suffix , '. ' ) !== 0 ) {
210- $ this -> suffix = '. ' . $ this -> suffix ;
217+ if ($ suffix !== '' && strpos ($ suffix , '. ' ) !== 0 ) {
218+ $ suffix = '. ' . $ suffix ;
211219 }
212220
221+ return $ suffix ;
222+ }
223+
224+ /**
225+ * @inheritDoc
226+ */
227+ public function setOptions (array $ options ): AdapterInterface
228+ {
229+ parent ::setOptions ($ options );
230+ $ this ->suffix = self ::getSuffix ($ options );
231+
213232 return $ this ;
214233 }
215234
0 commit comments