Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QueryBuilder For with Links throws EdgeDBErrorException #5

Open
Syzuna opened this issue Oct 21, 2022 · 4 comments
Open

QueryBuilder For with Links throws EdgeDBErrorException #5

Syzuna opened this issue Oct 21, 2022 · 4 comments
Assignees

Comments

@Syzuna
Copy link

Syzuna commented Oct 21, 2022

Summary

When trying to do a bulk insert with a "for" the query builder creates a faulty query that results in an EdgeDBErrorException.

Code

return await QueryBuilder
        .For(factions, faction => QueryBuilder.Insert(faction, false))
        .ExecuteAsync(_edgeDb, token: cancellationToken);

Stacktrace

EdgeDB[1] Failed to execute query EdgeDB.EdgeDBErrorException: object type or alias 'default::TLIZEJSNTVCU_d1' does not exist    at EdgeDB.EdgeDBBinaryClient.<>c__DisplayClass49_1.<ExecuteInternalAsync>g__parseHandlerPredicate|2(IReceiveable packet)    at EdgeDB.ClientPacketDuplexer.<>c__DisplayClass31_0.<NextAsync>b__0(IReceiveable t) --- End of stack trace from previous location ---    at EdgeDB.ClientPacketDuplexer.NextAsync(Predicate`1 predicate, Boolean alwaysReturnError, CancellationToken token)    at EdgeDB.ClientPacketDuplexer.DuplexAsync(Predicate`1 predicate, Boolean alwaysReturnError, CancellationToken token, Sendable[] packets)    at EdgeDB.EdgeDBBinaryClient.ExecuteInternalAsync(String query, IDictionary`2 args, Nullable`1 cardinality, Nullable`1 capabilities, IOFormat format, Boolean isRetry, CancellationToken token)

Generated Query

for faction in json_array_unpack(
  <json>$YAZBVRJPGFFH
)
union (
  insert Faction {
    name := <str>json_get(
      faction,
      'Name'
    ),
    is_player_faction := <bool>json_get(
      faction,
      'IsPlayerFaction'
    ),
    allegiance := <str>json_get(
      faction,
      'Allegiance'
    ),
    government := <str>json_get(
      faction,
      'Government'
    ),
    home_star_system := (
      select TLIZEJSNTVCU_d1 offset <int64>json_get(
        faction,
        'HomeStarSystem',
        'TLIZEJSNTVCU_depth_index'
      )
      limit 1
    )
    if json_typeof(
      json_get(
        faction,
        'HomeStarSystem'
      )
    )
    != 'null' else <StarSystem>{}
  }
)

Original report on archived repo: quinchs/EdgeDB.Net#32

@quinchs quinchs self-assigned this Nov 8, 2022
@quinchs
Copy link
Collaborator

quinchs commented Nov 8, 2022

Does this still happen with the most recent version?

@Syzuna
Copy link
Author

Syzuna commented Nov 8, 2022

Cannot test if that issue is fixed or not.
I run into another issue now:

EdgeDB[10] Error occured while reading binary stream System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.    at EdgeDB.Binary.ClientPacketDuplexer.ReadExactAsync(Memory`1 buffer, CancellationToken token)    at EdgeDB.Binary.ClientPacketDuplexer.ReadAsync()

@Syzuna
Copy link
Author

Syzuna commented Nov 8, 2022

ok retested with correct version this time after myget finally updated.
this still seems to be an issue yes.

EdgeDB[1] Failed to execute query InvalidReferenceError: object type or alias 'default::WGNYYHPYXYQQ_d1' does not exist
   |
 1 | for faction in json_array_unpack(<json>$XDSEOGGMJMGY) union (select (insert Faction { name := <str>json_get(faction, 'Name'), is_player_faction := <bool>json_get(faction, 'IsPlayerFaction'), allegiance := <str>json_get(faction, 'Allegiance'), government := <str>json_get(faction, 'Government'), home_star_system := (select WGNYYHPYXYQQ_d1 offset <int64>json_get(faction, 'HomeStarSystem', 'WGNYYHPYXYQQ_depth_index') limit 1) if json_typeof(json_get(faction, 'HomeStarSystem')) != 'null' else <StarSystem>{} }) { name, eddb_id, is_player_faction, allegiance, government, home_star_system: { name, id64, eddb_id, coord_x, coord_y, coord_z, allegiance, government, economies, security, population, powers, power_state, active_states, system_controlling_faction: { name, eddb_id, is_player_faction, allegiance, government }, faction_presences: { ref_id, is_active, is_native }, stations: { name, type, market_id64, distance_to_arrival, max_landing_pad_size, allegiance, government, economies, services, active_states } } })
   |                                                                                                                                                                                                                                                                                                                                    ^^^^^^^^^^^^^^^
    at EdgeDB.EdgeDBBinaryClient.ExecuteInternalAsync[TResult](String query, IDictionary`2 args, Nullable`1 cardinality, Nullable`1 capabilities, IOFormat format, Boolean isRetry, CancellationToken token)

@quinchs
Copy link
Collaborator

quinchs commented Nov 9, 2022

Alright this FOR operator is cursed, will look into this soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants