Sha256: 85cb9e3585c967d1909645ff1eaab39674eec678ebac12d609eab416b807847a

Contents?: true

Size: 773 Bytes

Versions: 17

Compression:

Stored size: 773 Bytes

Contents

module OrientDB::SQL
  class Insert

    include OrientDB::SQL::UtilsMixin
    include OrientDB::SQL::ClassClusterParametersMixin
    include OrientDB::SQL::FieldsValuesParametersMixin

    def initialize
      @oclass  = nil
      @cluster = nil
      @fields  = []
      @values  = []
    end

    def to_s
      (target_sql(:insert_into) + fields_sql + values_sql).strip
    end

    def to_sql_command
      OrientDB::SQLCommand.new to_s
    end

    private

    def fields_sql
      raise "Missing fields" if @fields.empty?
      "(#{@fields.join(', ')}) "
    end

    def values_sql
      raise "Missing values" if @values.empty?
      raise "Unbalanced fields & values" unless @values.size == @fields.size
      "VALUES (#{@values.join(', ')}) "
    end

  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
orientdb-1.7.8-java lib/orientdb/sql/insert.rb
orientdb-1.6.3-java lib/orientdb/sql/insert.rb
orientdb-1.5.0-java lib/orientdb/sql/insert.rb
orientdb-1.3.0-java lib/orientdb/sql/insert.rb
orientdb-1.2.0-java lib/orientdb/sql/insert.rb
orientdb-1.2.0 lib/orientdb/sql/insert.rb
orientdb-0.0.25-jruby lib/orientdb/sql/insert.rb
orientdb-0.0.24-jruby lib/orientdb/sql/insert.rb
orientdb-0.0.23-jruby lib/orientdb/sql/insert.rb
orientdb-0.0.22-jruby lib/orientdb/sql/insert.rb
orientdb-0.0.21-jruby lib/orientdb/sql/insert.rb
orientdb-0.0.20-jruby lib/orientdb/sql/insert.rb
orientdb-0.0.19-jruby lib/orientdb/sql/insert.rb
orientdb-0.0.17-jruby lib/orientdb/sql/insert.rb
orientdb-0.0.16-jruby lib/orientdb/sql/insert.rb
orientdb-0.0.15-jruby lib/orientdb/sql/insert.rb
orientdb-0.0.14-jruby lib/orientdb/sql/insert.rb