Code Monkey home page Code Monkey logo

Comments (7)

ethras avatar ethras commented on June 3, 2024 1

CleanShot 2024-04-01 at 01 07 21@2x
Yes it's correctly typed but typescript complains

from edgedb-js.

scotttrinh avatar scotttrinh commented on June 3, 2024 1

Thanks for the report! We've been iterating on these, so I'll make sure we have test coverage here once we get it fixed.

from edgedb-js.

scotttrinh avatar scotttrinh commented on June 3, 2024 1

Looks like this is a misalignment of canary versions of the driver (which defines the introspection queries) and the generate module. See if you can update to the latest canary on both the driver package (edgedb) and the generator package (@edgedb/generate) and get it working. I've added some tests in a separate PR that ensures we don't break this again in the future.

from edgedb-js.

scotttrinh avatar scotttrinh commented on June 3, 2024

This is working as intended since that query does not throw if it doesn't find an object with that ID, it returns null instead. If you want the query to fail with a database error you could wrap that query in an assert_exists which will cause the query cardinality to be exactly one, which seems like the behavior you are expecting here.

from edgedb-js.

scotttrinh avatar scotttrinh commented on June 3, 2024

Oh actually the cardinality seems like it is wrong in your example, it should be using querySingle. Are you sure the query you are testing is filtering on exclusive property like in your example code above?

from edgedb-js.

ethras avatar ethras commented on June 3, 2024

Oh actually the cardinality seems like it is wrong in your example, it should be using querySingle. Are you sure the query you are testing is filtering on exclusive property like in your example code above?

Yes, I had a complex query before but then I also tested with this simple one. it was working fine before I upgraded to canary from the latest version 0.4.1

from edgedb-js.

scotttrinh avatar scotttrinh commented on June 3, 2024

Is your TestReturns type correctly typed as | null? When I run this on master, I get the following:

export type ExclusiveArgs = Readonly<{
  "id": string;
}>;

export type ExclusiveReturns = {
  "name": string;
  "id": string;
  "number_of_movies": number | null;
  "secret_identity": string | null;
  "height": string | null;
} | null;

export function exclusive(client: Executor, args: ExclusiveArgs): Promise<ExclusiveReturns> {
  return client.query(`\
select Hero {*} filter .id = <uuid>$id;`, args);

}

Which is correct for the types, although it isn't using querySingle (I'll look into that).

from edgedb-js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.