Giter Site home page Giter Site logo

Comments (2)

maxsum-corin avatar maxsum-corin commented on July 23, 2024

This does not work for me (I'm using MS SQL Server) because the operator & doesn't return a boolean result (it's a number). I am using "& #{value} =" instead of '&'.

I would like to see the addition of a :has operator to the adapter(s).

Note that my definition is different to yours ("role" & ? = ? cf. "role" & ? <> 0). I am interpreting User.all('role.hasflag' => [:moderator, :editor]) as "all users that have both moderator and editor roles" as opposed to "all users that have either moderator and editor roles."

Edit: I made a new version of your pastebin: http://pastebin.com/Bak81f2Q

from dm-types.

todd-richmond avatar todd-richmond commented on July 23, 2024

Here is a more complete version of comparison_statement for Flags that handles all operators

      column_name = property_to_column_name(subject, qualify)
      value = value.inject(0, :+) if value.is_a?(Array)
      case comparison.slug
      when :eql then "#{column_name} = #{value}"
      when :gt then "#{column_name} & #{value} = #{value} AND #{column_name} != #{value}"
      when :gte then "#{column_name} & #{value} = #{value}"
      when :in, :like then value == 0 ? "TRUE" : "#{column_name} & #{value} != 0"
      when :lt then "#{column_name} & #{value} != #{value}"
      when :lte then "#{column_name} & #{value} <= #{value}"
      else 'FALSE'
      end

from dm-types.

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.