diff --git a/README.md b/README.md
index 9b7e89b1..247b66ee 100644
--- a/README.md
+++ b/README.md
@@ -1725,7 +1725,7 @@ Substitution Description
{lf} A line feed: '\n', alias for {newline}
{cr} A carriage return: '\r'
{crlf} a carriage return + line feed: '\r\n'
-{osxphotos_version} The osxphotos version, e.g. '0.45.5'
+{osxphotos_version} The osxphotos version, e.g. '0.45.6'
{osxphotos_cmd_line} The full command line used to run osxphotos
The following substitutions may result in multiple values. Thus if specified for
@@ -3629,7 +3629,7 @@ The following template field substitutions are availabe for use the templating s
|{lf}|A line feed: '\n', alias for {newline}|
|{cr}|A carriage return: '\r'|
|{crlf}|a carriage return + line feed: '\r\n'|
-|{osxphotos_version}|The osxphotos version, e.g. '0.45.5'|
+|{osxphotos_version}|The osxphotos version, e.g. '0.45.6'|
|{osxphotos_cmd_line}|The full command line used to run osxphotos|
|{album}|Album(s) photo is contained in|
|{folder_album}|Folder path + album photo is contained in. e.g. 'Folder/Subfolder/Album' or just 'Album' if no enclosing folder|
diff --git a/docs/.buildinfo b/docs/.buildinfo
index 47fbcf80..1ae6484b 100644
--- a/docs/.buildinfo
+++ b/docs/.buildinfo
@@ -1,4 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
-config: 99a74e6a82cae702311959821c897fdd
+config: 3c4bdd115410fda411407689f33d7c4c
tags: 645f666f9bcd5a90fca523b33c5a78b7
diff --git a/docs/_static/documentation_options.js b/docs/_static/documentation_options.js
index c5397270..3beb3c58 100644
--- a/docs/_static/documentation_options.js
+++ b/docs/_static/documentation_options.js
@@ -1,6 +1,6 @@
var DOCUMENTATION_OPTIONS = {
URL_ROOT: document.getElementById("documentation_options").getAttribute('data-url_root'),
- VERSION: '0.45.5',
+ VERSION: '0.45.6',
LANGUAGE: 'None',
COLLAPSE_INDEX: false,
BUILDER: 'html',
diff --git a/docs/cli.html b/docs/cli.html
index 1ccc3107..cc0d53ea 100644
--- a/docs/cli.html
+++ b/docs/cli.html
@@ -6,7 +6,7 @@
-
osxphotos command line interface (CLI) — osxphotos 0.45.5 documentation
+ osxphotos command line interface (CLI) — osxphotos 0.45.6 documentation
diff --git a/docs/genindex.html b/docs/genindex.html
index 15935b50..7c2ccd23 100644
--- a/docs/genindex.html
+++ b/docs/genindex.html
@@ -5,7 +5,7 @@
- Index — osxphotos 0.45.5 documentation
+ Index — osxphotos 0.45.6 documentation
diff --git a/docs/index.html b/docs/index.html
index 12ad77f8..519c2de4 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -6,7 +6,7 @@
- Welcome to osxphotos’s documentation! — osxphotos 0.45.5 documentation
+ Welcome to osxphotos’s documentation! — osxphotos 0.45.6 documentation
diff --git a/docs/modules.html b/docs/modules.html
index 0539e9b6..4e87650b 100644
--- a/docs/modules.html
+++ b/docs/modules.html
@@ -6,7 +6,7 @@
- osxphotos — osxphotos 0.45.5 documentation
+ osxphotos — osxphotos 0.45.6 documentation
diff --git a/docs/reference.html b/docs/reference.html
index 3f1c25d3..c2130858 100644
--- a/docs/reference.html
+++ b/docs/reference.html
@@ -6,7 +6,7 @@
- osxphotos package — osxphotos 0.45.5 documentation
+ osxphotos package — osxphotos 0.45.6 documentation
diff --git a/docs/search.html b/docs/search.html
index 2952734b..b3af0452 100644
--- a/docs/search.html
+++ b/docs/search.html
@@ -5,7 +5,7 @@
- Search — osxphotos 0.45.5 documentation
+ Search — osxphotos 0.45.6 documentation
diff --git a/osxphotos/photosdb/photosdb.py b/osxphotos/photosdb/photosdb.py
index 6dda50ee..05764f3f 100644
--- a/osxphotos/photosdb/photosdb.py
+++ b/osxphotos/photosdb/photosdb.py
@@ -39,6 +39,7 @@ from .._constants import (
_PHOTOS_5_PROJECT_ALBUM_KIND,
_PHOTOS_5_ROOT_FOLDER_KIND,
_PHOTOS_5_SHARED_ALBUM_KIND,
+ _PHOTOS_5_VERSION,
_TESTED_OS_VERSIONS,
_UNKNOWN_PERSON,
BURST_KEY,
@@ -3308,23 +3309,35 @@ class PhotosDB:
# case-insensitive
for n in name:
n = n.lower()
- photo_list.extend(
- [
- p
- for p in photos
- if n in p.filename.lower()
- or n in p.original_filename.lower()
- ]
- )
+ if self._db_version >= _PHOTOS_5_VERSION:
+ # search only original_filename (#594)
+ photo_list.extend(
+ [p for p in photos if n in p.original_filename.lower()]
+ )
+ else:
+ photo_list.extend(
+ [
+ p
+ for p in photos
+ if n in p.filename.lower()
+ or n in p.original_filename.lower()
+ ]
+ )
else:
for n in name:
- photo_list.extend(
- [
- p
- for p in photos
- if n in p.filename or n in p.original_filename
- ]
- )
+ if self._db_version >= _PHOTOS_5_VERSION:
+ # search only original_filename (#594)
+ photo_list.extend(
+ [p for p in photos if n in p.original_filename]
+ )
+ else:
+ photo_list.extend(
+ [
+ p
+ for p in photos
+ if n in p.filename or n in p.original_filename
+ ]
+ )
photos = photo_list
if options.min_size:
diff --git a/tests/test_cli.py b/tests/test_cli.py
index 0f93084f..792b456a 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -7186,6 +7186,46 @@ def test_query_name_i():
assert json_got[0]["original_filename"] == "DSC03584.dng"
+def test_query_name_original_filename():
+ """test query --name only searches original filename on Photos 5+"""
+ import json
+ import os
+ import os.path
+
+ from osxphotos.cli import query
+
+ runner = CliRunner()
+ cwd = os.getcwd()
+ result = runner.invoke(
+ query,
+ ["--json", "--db", os.path.join(cwd, PHOTOS_DB_15_7), "--name", "AA"],
+ )
+ assert result.exit_code == 0
+ json_got = json.loads(result.output)
+
+ assert len(json_got) == 4
+
+
+def test_query_name_original_filename_i():
+ """test query --name only searches original filename on Photos 5+ with -i"""
+ import json
+ import os
+ import os.path
+
+ from osxphotos.cli import query
+
+ runner = CliRunner()
+ cwd = os.getcwd()
+ result = runner.invoke(
+ query,
+ ["--json", "--db", os.path.join(cwd, PHOTOS_DB_15_7), "--name", "aa", "-i"],
+ )
+ assert result.exit_code == 0
+ json_got = json.loads(result.output)
+
+ assert len(json_got) == 4
+
+
def test_export_name():
"""test export --name"""
import glob