Skip to content

json: AsText method unnecessarily returns pointer to string and error #81097

@knz

Description

@knz

Noticed while working on #80000: the method AsText() in json.JSON returns (*string, error).

I think it's silly?

  • none of the methods actually return an error. It's unnecessary to pay the price of a 2nd error return.
  • all of the methods create a string and then allocate (on the heap) a reference to it. Why not returning the string directly?

Also, why not use the .String() method directly, which seems to do the same? (edit: nvm)

cc @yuzefovich

Jira issue: CRDB-15147

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-sql-jsonJSON handling in SQL.C-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.E-quick-winLikely to be a quick win for someone experienced.T-sql-queriesSQL Queries Team

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions