Skip to content

Fix RTE in ActiveRecord adapter when using null string filter#410

Closed
smai-f wants to merge 3 commits into
graphiti-api:masterfrom
smai-f:allow-nil-filter-in-activerecord-adapter
Closed

Fix RTE in ActiveRecord adapter when using null string filter#410
smai-f wants to merge 3 commits into
graphiti-api:masterfrom
smai-f:allow-nil-filter-in-activerecord-adapter

Conversation

@smai-f

@smai-f smai-f commented Apr 11, 2022

Copy link
Copy Markdown

If one's resource is backed by ActiveRecord, an RTE is thrown if one allows nil and tries to filter by null on a string value. The adapter maps the filter values with downcase without checking for nil.

@richmolj

@richmolj

Copy link
Copy Markdown
Contributor

Thanks so much! Would you mind adding a test for this and I will merge?

@smai-f

smai-f commented Jul 28, 2022

Copy link
Copy Markdown
Author

Not ready yet, something is differing between how the appraisal spec and our (older) monkeypatched version of Graphiti is constructing the eq: 'null' clause.

Monkeypatched version clause (correct behavior, see last line)

=> #<Arel::Nodes::Grouping:0x0000000010b16b50
 @expr=
  #<Arel::Nodes::Equality:0x0000000010b16c40
   @left=
    #<Arel::Nodes::NamedFunction:0x0000000010b17460
     @alias=nil,
     @distinct=false,
     @expressions=
      [#<struct Arel::Attributes::Attribute
        relation=
         #<Arel::Table:0x0000000018da0ff8
          @name="monkeypatched_resource",
          @table_alias=nil,
          @type_caster=
           #<ActiveRecord::TypeCaster::Map:0x0000000018da1048
            @types= <list of attributes>
     @name="LOWER">,
   @right=
    #<Arel::Nodes::Quoted:0x0000000010b16c90
     @expr=nil>>>

Spec version clause (last line expression is "null" not nil)

=> #<Arel::Nodes::Grouping:0x00007f885dcc3318
 @expr=
  #<Arel::Nodes::Equality:0x00007f885dcc3390
   @left=
    #<Arel::Nodes::NamedFunction:0x00007f885dcc34d0
     @alias=nil,
     @distinct=false,
     @expressions=
      [#<struct Arel::Attributes::Attribute
        relation=
         #<Arel::Table:0x00007f883db737f8
          @name="authors",
          @table_alias=nil,
          @type_caster=
           #<ActiveRecord::TypeCaster::Map:0x00007f883db73848
            @types=
             Legacy::Author(id: integer, active: boolean, first_name: string, last_name: string, age: integer, float_age: float, decimal_age: float, dwelling_type: string, state_id: integer, dwelling_id: integer, organization_id: integer, created_at_date: date, last_login: datetime, identifier: string, created_at: datetime, updated_at: datetime)>>,
        name=:last_name>],
     @name="LOWER">,
   @right=#<Arel::Nodes::Quoted:0x00007f885dcc33e0 @expr="null">>>

@smai-f smai-f closed this May 11, 2023
amaierhofer added a commit to amaierhofer/graphiti that referenced this pull request Feb 18, 2026
This currently fails with

`Unsupported argument type: NilClass. Construct an Arel node instead.`

when the scope is resolved.

Prior art from graphiti-api#410
amaierhofer added a commit to amaierhofer/graphiti that referenced this pull request Feb 18, 2026
This currently fails with

`Unsupported argument type: NilClass. Construct an Arel node instead.`

when the scope is resolved.

Prior art from graphiti-api#410
amaierhofer added a commit to amaierhofer/graphiti that referenced this pull request Feb 18, 2026
This currently fails with

`Unsupported argument type: NilClass. Construct an Arel node instead.`

when the scope is resolved.

Prior art from graphiti-api#410
amaierhofer added a commit to amaierhofer/graphiti that referenced this pull request Feb 18, 2026
This currently fails with

`Unsupported argument type: NilClass. Construct an Arel node instead.`

when the scope is resolved.

Prior art from graphiti-api#410
amaierhofer added a commit to amaierhofer/graphiti that referenced this pull request Feb 18, 2026
This currently fails with

`Unsupported argument type: NilClass. Construct an Arel node instead.`

when the scope is resolved.

Prior art from graphiti-api#410
amaierhofer added a commit to amaierhofer/graphiti that referenced this pull request Feb 18, 2026
This currently fails with

`Unsupported argument type: NilClass. Construct an Arel node instead.`

when the scope is resolved.

Prior art from graphiti-api#410
amaierhofer added a commit to amaierhofer/graphiti that referenced this pull request Feb 18, 2026
This currently fails with

`Unsupported argument type: NilClass. Construct an Arel node instead.`

when the scope is resolved.

Prior art from graphiti-api#410
amaierhofer added a commit to amaierhofer/graphiti that referenced this pull request Feb 19, 2026
This currently fails with

`Unsupported argument type: NilClass. Construct an Arel node instead.`

when the scope is resolved.

Prior art from graphiti-api#410
amaierhofer added a commit to amaierhofer/graphiti that referenced this pull request Apr 15, 2026
This currently fails with

`Unsupported argument type: NilClass. Construct an Arel node instead.`

when the scope is resolved.

Prior art from graphiti-api#410
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants