Sha256: fe140eaecb5d22193d741dbfbfbf988d4b262f429f0cfdeaa700f6a775dcff67

Contents?: true

Size: 841 Bytes

Versions: 11

Compression:

Stored size: 841 Bytes

Contents

require "spec_helper"

describe Baza::SqlQueries::GenericInsert do
  let(:constant) do
    const_name = "InfoPg"
    require StringCases.camel_to_snake(const_name)
    raise "Constant was not defined: '#{const_name}'." unless Baza.const_defined?(const_name)
    Baza.const_get(const_name)
  end
  let(:db) { constant.new.db }

  describe "#convert_line_breaks" do
    it "converts line breaks to valid postgres sql" do
      generic_insert = Baza::SqlQueries::GenericInsert.new(
        db: db,
        table_name: "test_table",
        data: {
          "test_column" => "data\nwith\nline\nbreaks"
        },
        replace_line_breaks: true
      )

      expect(generic_insert.to_sql).to eq "INSERT INTO \"test_table\" (\"test_column\") VALUES ('data' || CHR(10) || 'with' || CHR(10) || 'line' || CHR(10) || 'breaks')"
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
baza-0.0.38 spec/baza/sql_queries/generic_insert_spec.rb
baza-0.0.37 spec/baza/sql_queries/generic_insert_spec.rb
baza-0.0.36 spec/baza/sql_queries/generic_insert_spec.rb
baza-0.0.35 spec/baza/sql_queries/generic_insert_spec.rb
baza-0.0.34 spec/baza/sql_queries/generic_insert_spec.rb
baza-0.0.33 spec/baza/sql_queries/generic_insert_spec.rb
baza-0.0.32 spec/baza/sql_queries/generic_insert_spec.rb
baza-0.0.31 spec/baza/sql_queries/generic_insert_spec.rb
baza-0.0.30 spec/baza/sql_queries/generic_insert_spec.rb
baza-0.0.29 spec/baza/sql_queries/generic_insert_spec.rb
baza-0.0.28 spec/baza/sql_queries/generic_insert_spec.rb