Skip to content

Fixed boolean conversion to int bug#5

Merged
Vishal Zambre (vishalzambre) merged 10 commits intomasterfrom
boolean-fix
Mar 21, 2023
Merged

Fixed boolean conversion to int bug#5
Vishal Zambre (vishalzambre) merged 10 commits intomasterfrom
boolean-fix

Conversation

@vishalzambre
Copy link
Copy Markdown

@vishalzambre Vishal Zambre (vishalzambre) commented Mar 16, 2023

After upgrade to rails 6.1.7.3 we started seeing that boolean was converting to integer tinybit. After investigation found that BOOLEAN_TYPE value needs to update.

Reference https://docs.snowflake.com/en/sql-reference/intro-summary-data-types

https://github.com/rails/rails/blob/main/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb#L877-L908

["number",
 "decimal",
 "numeric",
 "int",
 "integer",
 "bigint",
 "smallint",
 "tinyint",
 "byteint",
 "float",
 "float4",
 "float8",
 "double",
 "real",
 "varchar",
 "char",
 "character",
 "string",
 "text",
 "binary",
 "varbinary",
 "boolean",
 "date",
 "datetime",
 "time",
 "timestamp",
 "timestamp_ltz",
 "timestamp_ntz",
 "timestamp_tz",
 "variant",
 "object",
 "array",
 "geography",
 "geometry"]

Possible mapping from chatgpt

Snowflake Data Type Ruby ActiveRecord Type PostgreSQL Type
number :decimal numeric
decimal :decimal numeric
numeric :decimal numeric
int :integer integer
integer :integer integer
bigint :bigint bigint
smallint :integer smallint
tinyint :integer smallint
byteint :integer smallint
float :float double precision
float4 :float real
float8 :float double precision
double :float double precision
real :float real
varchar :string character varying
char :string character
character :string character
string :string character varying
text :text text
binary :binary bytea
varbinary :binary bytea
boolean :boolean boolean
date :date date
datetime :datetime timestamp without time zone
time :time time without time zone
timestamp :timestamp timestamp without time zone
timestamp_ltz :timestamp timestamp without time zone
timestamp_ntz :timestamp timestamp without time zone
timestamp_tz :timestamp timestamp with time zone
variant :jsonb jsonb
object :jsonb jsonb
array :jsonb jsonb
geography :st_point, :st_polygon, geography
:st_multipolygon
geometry :st_point, :st_polygon, geometry
:st_multipolygon

if database_metadata.upcase_identifiers?
return name unless name =~ /([A-Z]+[a-z])|([a-z]+[A-Z])/
end
return name if database_metadata.upcase_identifiers? && name !~ /([A-Z]+[a-z])|([a-z]+[A-Z])/

Check failure

Code scanning / CodeQL

Polynomial regular expression used on uncontrolled data

This [regular expression](1) that depends on a [library input](2) may run slow on strings with many repetitions of 'A'. This [regular expression](3) that depends on a [library input](2) may run slow on strings with many repetitions of 'a'. This [regular expression](1) that depends on a [library input](4) may run slow on strings with many repetitions of 'A'. This [regular expression](3) that depends on a [library input](4) may run slow on strings with many repetitions of 'a'. This [regular expression](1) that depends on a [library input](5) may run slow on strings with many repetitions of 'A'. This [regular expression](3) that depends on a [library input](5) may run slow on strings with many repetitions of 'a'. This [regular expression](1) that depends on a [library input](6) may run slow on strings with many repetitions of 'A'. This [regular expression](3) that depends on a [library input](6) may run slow on strings with many repetitions of 'a'. This [regular expression](1) that depends on a [library input](7) may run slow on strings with many repetitions of 'A'. This [regular expression](3) that depends on a [library input](7) may run slow on strings with many repetitions of 'a'.
@vishalzambre Vishal Zambre (vishalzambre) deleted the boolean-fix branch March 21, 2023 08:34
@vishalzambre Vishal Zambre (vishalzambre) restored the boolean-fix branch March 21, 2023 08:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants