Skip to content

Commit 7298d93

Browse files
committed
Remove .ome from file name generated
1 parent a14c0cd commit 7298d93

File tree

1 file changed

+15
-2
lines changed
  • packages/core/services/DatabaseService

1 file changed

+15
-2
lines changed

packages/core/services/DatabaseService/index.ts

+15-2
Original file line numberDiff line numberDiff line change
@@ -205,13 +205,26 @@ export default abstract class DatabaseService {
205205
`);
206206
// Best shot attempt at auto-generating a "File Name"
207207
// from the "File Path", defaults to full path if this fails
208+
// description of SQL:
209+
// * COALESCE - returns the first non-null value in the list
210+
// * NULLIF - returns null if the two arguments are equal
211+
// * REGEXP_REPLACE - replaces a substring with another substring
212+
// so we first replace the last file extension with nothing
213+
// then check if .ome is at the end of the string and remove it
214+
// then if it is null if the string is empty
215+
// which we use COALESCE to replace with the full path if so
208216
commandsToExecute.push(`
209217
UPDATE "${name}"
210218
SET "${PreDefinedColumn.FILE_NAME}" = COALESCE(
211219
NULLIF(
212220
REGEXP_REPLACE(
213-
"${PreDefinedColumn.FILE_PATH}",
214-
'^.*/([^/]*?)(\\.[^/.]+)?$', '\\1',
221+
REGEXP_REPLACE(
222+
"${PreDefinedColumn.FILE_PATH}",
223+
'^.*/([^/]*?)(\\.[^/.]+)?$',
224+
'\\1',
225+
''
226+
),
227+
'\\.ome$',
215228
''
216229
),
217230
''),

0 commit comments

Comments
 (0)