MagicStack / MagicStack/asyncpg

[Question] Generate Record from Record subset of keys?

Open
#407 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
8.1k
Forks
468
PR merge metrics
No merged PRs in 30d

Description

Hi guys!

Really great library, well done and hats off to you.

Just a small question: can I generate a Record from a subset of another Record's keys? e.g.:

record: Record = conn.fetchrow(query, foo)
print(len(record.keys()) # let's say there are 10 keys

# Make a new Record from the first 8 keys
new_record = Record(record[:8])

The reason I can't just cast the original Record to a dict is because it was generated using 2 INNER JOINs onto the same table, and so I have non-unique column descriptions in the result from that query.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with asyncpg's Record API and the conn.fetchrow result described in the example; the issue names no source files or tests. Determine whether constructing a Record from a subset of keys is supported, and clarify the supported approach for results with duplicate column names.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql, python
Domain
databases
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.