SQLite NOCASE and BINARY: Check Identifier Equality Before Merging Drone Records
Compare built-in BINARY and NOCASE equality on invented drone record identifiers, preserving original spelling and the limits of ASCII case folding.

Separate a string match from an asset identity decision
A drone handoff register may contain identifiers that differ only in letter case. Before combining records, determine which comparison rule the report used and whether the project treats those spellings as the same identifier. A match in one SQL expression does not establish that two rows describe one physical asset. This tutorial compares the built-in BINARY and NOCASE collations in SQLite using invented strings. It does not open a NiVO register, delete duplicates or prescribe a naming convention for an actual customer delivery. The result is a small, reproducible equality observation.
Keep the original strings and stable row references with the comparison. If one export has converted every identifier to uppercase, that transformation belongs in the evidence. A recipient who sees only a matched flag cannot tell whether the source values were identical, differed in case or were rewritten before the query ran. State what the identifier represents and who owns its rules. A display label, a file name and a database key may have different contracts, so a convenient comparison policy should not silently migrate between them.
Read the limits of the built-in comparison rule
SQLite documents BINARY as its binary string comparison and NOCASE as a related comparison that folds the twenty-six uppercase ASCII letters to lowercase equivalents. Built-in NOCASE does not perform full Unicode case folding. An explicit COLLATE assignment selects the comparison used by the expression. The demonstration names both collations rather than relying on a column declaration that might be hidden in a schema. Its parameters are text values, and it does not register a custom collation or load an extension. These boundaries make the observed behavior easier to reproduce.
The word NOCASE can be misleading if it is read as a promise about every writing system. In the invented accented pair below, the capital and lowercase accented characters remain distinct under this built-in rule. That result is not evidence that either spelling is wrong. It shows that the rule has a defined scope. If a real identifier contract requires another comparison, document and implement that contract separately. Do not describe a broad Unicode policy as tested merely because one ASCII example happened to match in a standard SQLite connection.

Product context only; this photograph does not depict the constructed examples in this article.
Run two explicit equality expressions without changing a register
Run the Python standard library function below. It accepts nonempty Unicode strings of at most sixty-four characters and rejects embedded null characters. Those restrictions define the local teaching profile, not a universal identifier standard. SQLite documents special null-character handling in NOCASE comparisons; excluding such characters keeps this demonstration focused on ordinary visible identifiers. The encoding check rejects unpaired surrogate values rather than allowing an unrelated encoding error to obscure the comparison. A real import needs a documented representation policy instead of silently stripping unexpected characters until a query can run.
The function binds the same two original values into both expressions and returns the inputs alongside boolean equality results. It opens only an in-memory connection and creates no table or project database. The connection closes after the comparison. The examples isolate ASCII case, an accented case difference and a trailing space. Using the same pair for both expressions matters: otherwise a changed result could come from different source data instead of the selected collation. Keep the exact query text with the output when another reviewer needs to reproduce a finding.
import sqlite3
def compare_identifiers(left, right):
for value in (left, right):
if type(value) is not str or not 1 <= len(value) <= 64 or "\x00" in value:
raise ValueError("expected bounded nonempty text without NUL")
try:
value.encode("utf-8")
except UnicodeEncodeError as error:
raise ValueError("expected valid Unicode scalar text") from error
con = sqlite3.connect(":memory:")
try:
binary, nocase = con.execute(
"SELECT ? COLLATE BINARY = ?, ? COLLATE NOCASE = ?",
(left, right, left, right)).fetchone()
return {"left_raw": left, "right_raw": right,
"binary_equal": bool(binary), "nocase_equal": bool(nocase)}
finally:
con.close()
for pair in [("tile-A", "TILE-a"), ("café", "CAFÉ"), ("tile-A", "tile-A ")]:
print(compare_identifiers(*pair))Explain each constructed result before choosing a policy
The ASCII pair produces binary_equal false and nocase_equal true. The accented pair produces false for both comparisons because the differing accented letter is outside the built-in ASCII fold. The trailing-space pair also produces false for both. A case-insensitive comparison is not a trimming operation, and a string that looks similar in a narrow table column can still contain an additional character. The helper retains the original strings so the result can be traced to the supplied pair rather than a rewritten version that happens to compare more conveniently.
Try two identical strings as a control: both results should be true. Then keep an accented character identical while changing only nearby ASCII letters. That pair can match under NOCASE because the non-ASCII character is unchanged and the changed characters fall within the supported ASCII fold. This controlled comparison is more informative than claiming that Unicode identifiers never match. The question is which characters differ and which transformations the chosen rule performs. Include unequal punctuation and a leading space as separate cases if those distinctions matter to the actual identifier contract.
Test the comparison without normalizing away the evidence
Test symmetry by reversing the two inputs and checking that the equality flags agree. Exercise every ASCII uppercase letter against its lowercase partner, and include accented and other non-ASCII pairs that should remain distinct in this profile. Keep expected results independent from the SQL implementation. For example, an ASCII-only translation table is a useful test oracle; a language runtime's broad case-folding operation would answer a different question. These tests establish the bounded comparison behavior, while the original register and the meaning of its identifiers remain outside the function.
Do not apply a matching rule by overwriting the source identifiers. A review can retain both spellings and record a proposed association separately. If another workflow trims, normalizes or folds strings before SQLite receives them, preserve that stage and test it on its own. Otherwise a successful equality test can hide an earlier transformation that created an unintended collision. A list of matching pairs is evidence about the selected expression on selected inputs. It is not, by itself, authorization to merge records or evidence that their geometry, imagery or inspection history belongs together.
Hand off the rule and the raw pair together
For a useful drone-data review, record the register revision, row references, original identifiers, query, SQLite version and chosen collation. Include a small counterexample that exposes the rule's limit, not only a pair that matches. If two reports disagree, compare the source strings and any prior transformations before interpreting the difference as a new duplicate or a missing asset. Keep unresolved identity questions visible. An explicit comparison makes the software behavior reproducible, but the project still needs evidence that the intended relationship between records is correct.
The owner-supplied NiVO photograph provides aircraft context only. It is not evidence of a particular database schema, customer inventory or duplicate-detection result. The practical habit is to name the comparison policy, preserve the original spelling and avoid giving a text match more meaning than it carries. With those details available, another reviewer can reproduce why BINARY and NOCASE disagree on an ASCII pair and why the built-in rule does not settle a wider language or identity question. That creates a clear starting point for a controlled handoff decision.



