Skip to content

Feature: Allowing filtering which fields to pick in select #237

@KevinvOosterhout

Description

@KevinvOosterhout

Is your feature request related to a problem?

At the moment when you use the SDK it forces a SELECT * FROM $thing. This prevents the scenario where you'd only want a single field to conserve data / compute / memory usage. This also prevents usage of relationships. for example ->tenant is not included by default.

Describe the solution

In my opinion the most pythonic way to do this is the following. Acccept a list[str] as a fields kwarg with the current * as a default fallback method. This would make implementation quite easy in the query, would be easy for the user to implement, and would not break existing implementation. This would allow this feature to be introduced without breaking changes.

Example:

db.select("user", fields=["name", "->tenant"])
db.select("user") # Would still work and when None is passed in the fields it should just do *

Alternative methods

I've seen the JS SDK does chained methods so db.select("user").fields(["name", "->tenant"]). This is probably not the best approach and more difficult to implement in Python.

SurrealDB version

3.0.0 for macos on aarch64

surrealdb.py version

main

Contact Details

kevin.oosterhout@nuxnova.io

Is there an existing issue for this?

  • I have searched the existing issues

Code of Conduct for repository surrealdb/surrealdb.py

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions