Skip to content

Commit 31652f6

Browse files
committed
feat: accept wildcards in filename
1 parent 0264047 commit 31652f6

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/SQLLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ public function inFile(
426426
?string $discardFile = null,
427427
?string $discardMax = null
428428
): static {
429-
if (! File::exists($path) && $path !== '*') {
429+
if (! File::exists($path) && ! Str::contains($path, ['*', '?'])) {
430430
throw new InvalidArgumentException("File [{$path}] does not exist.");
431431
}
432432

tests/Unit/InputFileTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,13 @@
3737

3838
expect($inputFile->__toString())->toBe("INFILE 'path/to/file' \"OS_FILE_PROC\" BADFILE 'path/to/badfile' DISCARDFILE 'path/to/discardfile' DISCARDMAX 1");
3939
});
40+
41+
test('it accepts wildcard in file path', function () {
42+
$inputFile = new InputFile('path/to/chunk-*.dat');
43+
44+
expect($inputFile->__toString())->toBe("INFILE 'path/to/chunk-*.dat'");
45+
46+
$inputFile = new InputFile('path/to/chunk-?.dat');
47+
48+
expect($inputFile->__toString())->toBe("INFILE 'path/to/chunk-?.dat'");
49+
});

0 commit comments

Comments
 (0)