lib/ronin/code/sql/replace.rb in ronin-sql-0.1.1 vs lib/ronin/code/sql/replace.rb in ronin-sql-0.2.0

- old
+ new

@@ -1,11 +1,11 @@ # #-- # Ronin SQL - A Ronin library providing support for SQL related security # tasks. # -# Copyright (c) 2007-2008 Hal Brodigan (postmodern.mod3 at gmail.com) +# Copyright (c) 2007-2009 Hal Brodigan (postmodern.mod3 at gmail.com) # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. @@ -20,37 +20,35 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #++ # require 'ronin/code/sql/statement' +require 'ronin/code/sql/fields_clause' +require 'ronin/code/sql/values_clause' +require 'ronin/code/sql/default_values_clause' module Ronin module Code module SQL class Replace < Statement - def initialize(style,table=nil,values=nil,from=nil,&block) - @table = table - @values = values - @from = from + clause :fields, FieldsClause + clause :default_values, DefaultValuesClause + clause :values, ValuesClause - super(style,&block) - end + def initialize(dialect,options={},&block) + @table = options[:table] - def values(data) - @values = data + super(dialect,options,&block) end - def from(expr) - @from = expr + def table(name) + @table = name + return value end - def compile - if @values.kind_of?(Hash) - return compile_expr('REPLACE INTO',@table,compile_list(@values.keys),'VALUES',compile_datalist(@values.values)) - elsif @from.kind_of?(Select) - return compile_expr('REPLACE INTO',@table,compile_list(@values),@from) - end + def emit + emit_token('REPLACE INTO') + emit_value(@table) + super end end end end