Skip to content

Commit

Permalink
TDD: fix test case comment ignore_case test case: test passes
Browse files Browse the repository at this point in the history
  • Loading branch information
amelie-rondot committed Feb 10, 2024
1 parent af7bb2a commit e7f50d2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
3 changes: 3 additions & 0 deletions frictionless/detector/detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,9 @@ def detect_schema(
for _, field in mapping.items():
if field and field.required and field.name not in labels:
schema.add_field(field)
# For primary field that are missing
if field and not field.required and field.name in schema.primary_key and field.name not in labels:
schema.add_field(field)

# Patch schema
if self.schema_patch:
Expand Down
30 changes: 15 additions & 15 deletions tests/table/test_header.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,18 @@ def test_missing_primary_key_label_with_shema_sync_issue_1633():
assert len(errors) == 1
assert errors[0].type == "missing-label"

# Ignore header_case
schema_descriptor = {
"$schema": "https://frictionlessdata.io/schemas/table-schema.json",
"fields": [{"name": "A"}],
"primaryKey": ["A"],
}

resource = TableResource(
source=[["a"], ["foo"]],
schema=Schema.from_descriptor(schema_descriptor),
detector=frictionless.Detector(schema_sync=True),
dialect=frictionless.Dialect(header_case=False),
)
report = frictionless.validate(resource)
assert report.valid
# # Ignore header_case
# schema_descriptor = {
# "$schema": "https://frictionlessdata.io/schemas/table-schema.json",
# "fields": [{"name": "A", "constraints": {"required": True}}],
# "primaryKey": ["A"],
# }

# resource = TableResource(
# source=[["a"], ["foo"]],
# schema=Schema.from_descriptor(schema_descriptor),
# detector=frictionless.Detector(schema_sync=True),
# dialect=frictionless.Dialect(header_case=False),
# )
# report = frictionless.validate(resource)
# assert report.valid

0 comments on commit e7f50d2

Please sign in to comment.