Skip to content

problem with filter shortcut method #57

@siemionides

Description

@siemionides

Hello,
today I've encountered the weird issue.
I have a model "Badge" in my Datomic db, here's it's ruby's representation:

 require 'diametric'

  class Badge
    include Diametric::Entity
    include Diametric::Persistence::Peer

    attribute :category, Ref
    attribute :date, DateTime
    attribute :description, String
    attribute :enum_value, String
    attribute :enumeration, String, :cardinality => :many
    attribute :id, UUID
    attribute :name, String
    attribute :type, Ref
    attribute :value, Double
    attribute :week, Integer
    attribute :year, Integer
  end

Im relying on Peer API, JRuby.
I want to get the badges with value >= 10.

Following code works fine:
badges = Diametric::Query.new(Badge, nil, true).filter(:>, :value, 9)
the badges.inspect returns
#<Diametric::Query:0x33de4104 @conditions={}, @filter_values=[9], @conn_or_db=nil, @filters=[[(> ?value ?valuevalue)]], @model=Badge, @resolve=true, @filter_attrs=[:value]>

and I'm free to iterate over set with

 badges.each do |badge|
      Grape::API.logger.info badge.inspect
  end

BUT when I'm trying to use shortcut method
badges = Badge.filter(:>, :value, 9)

the badges.inspect returns
#<Diametric::Query:0x1e7a60f7 @conditions={}, @filter_values=[9], @conn_or_db=:>, @filters=[[(?value ?valuevalue)]], @model=Badge, @resolve=true, @filter_attrs=[:value]>

(please mind the @conn_or_db or @filters keys)

and when i'm trying to iterate over set I'm being given

ArgumentError: The second arg should be a database.
    diametric/DiametricPeer.java:270:in `q'
    /Users/michalsiemionczyk/.rvm/gems/jruby-1.7.15/gems/diametric-0.1.3-java/lib/diametric/persistence/peer.rb:191:in `q'
    /Users/michalsiemionczyk/.rvm/gems/jruby-1.7.15/gems/diametric-0.1.3-java/lib/diametric/query.rb:117:in `each'
    /Users/michalsiemionczyk/Projects/yeti-backend/app/services/profiles/filtered_profiles_service.rb:37:in `query_for_date_filtered'

which points to the badges.each do |badge| .

I guess it might a bug relating to definition of filter shortcut method,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions