Skip to content

Conversation

@dimitri-yatsenko
Copy link
Member

Summary

Fix fetch('column') to return an array like DJ 1.x, not a list of dicts.

Problem

# DJ 1.x behavior (expected):
names = Table().fetch("name")  # array(['alpha', 'beta'])
"alpha" in names  # True

# DJ 2.0 broken behavior:
names = Table().fetch("name")  # [{'name': 'alpha'}, {'name': 'beta'}]
"alpha" in names  # False  ← breaks existing code!

Root Cause

In expression.py:642, the condition:

if as_dict or as_dict is None:

Treats unspecified as_dict the same as True, returning dicts instead of arrays.

Fix

Change to:

if as_dict is True:

So that unspecified as_dict defaults to array output, matching DJ 1.x.

Behavior After Fix

Pattern Returns
fetch('col') array (DJ 1.x compatible)
fetch('col', as_dict=False) array
fetch('col', as_dict=True) list of dicts

Testing

  • Updated test_fetch_with_attrs_returns_arrays to verify correct behavior
  • Added test_fetch_with_attrs_as_dict_true for explicit dict case
  • All 10 fetch compat tests pass

🤖 Generated with Claude Code

In DJ 1.x, fetch('column') returns an array like ['alpha', 'beta'].
The previous implementation incorrectly returned list of dicts when
as_dict was not specified.

Fix: Change condition from `if as_dict or as_dict is None` to
`if as_dict is True` so unspecified as_dict defaults to array output.

Before (broken):
  names = Table().fetch("name")  # [{'name': 'alpha'}, {'name': 'beta'}]
  "alpha" in names  # False

After (matches DJ 1.x):
  names = Table().fetch("name")  # array(['alpha', 'beta'])
  "alpha" in names  # True

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@github-actions github-actions bot added bug Indicates an unexpected problem or unintended behavior enhancement Indicates new improvements labels Jan 30, 2026
@esutlie esutlie merged commit 6e196cd into master Jan 30, 2026
8 checks passed
@esutlie esutlie deleted the fix/fetch-attrs-array branch January 30, 2026 22:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Indicates an unexpected problem or unintended behavior enhancement Indicates new improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants