Merge pull request #1249 from pskillen/bugfix-version-field-bigdecimal

Fix Version field interpreting int as BigDecimal
This commit is contained in:
Karel Picman 2021-05-06 17:55:39 +02:00 committed by GitHub
commit 1ecaf67e74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 25 deletions

View File

@ -207,6 +207,7 @@ module DmsfUploadHelper
# 1 -> 1, -65 -> A
def self.gui_version(version)
version = version.to_i # catch the case where version is a BigDecimal
return version if version >= 0
(-version).chr
end

View File

@ -199,20 +199,20 @@ class DmsfQuery < Query
scope = Project.select(%{
projects.id AS id,
projects.id AS project_id,
CAST(NULL AS #{ActiveRecord::Base.connection.type_to_sql(:decimal)}) AS revision_id,
CAST(NULL AS #{ActiveRecord::Base.connection.type_to_sql(:integer)}) AS revision_id,
projects.name AS title,
projects.identifier AS filename,
CAST(NULL AS #{ActiveRecord::Base.connection.type_to_sql(:decimal)}) AS size,
CAST(NULL AS #{ActiveRecord::Base.connection.type_to_sql(:integer)}) AS size,
projects.updated_on AS updated,
CAST(NULL AS #{ActiveRecord::Base.connection.type_to_sql(:decimal)}) AS major_version,
CAST(NULL AS #{ActiveRecord::Base.connection.type_to_sql(:decimal)}) AS minor_version,
CAST(NULL AS #{ActiveRecord::Base.connection.type_to_sql(:decimal)}) AS workflow,
CAST(NULL AS #{ActiveRecord::Base.connection.type_to_sql(:decimal)}) AS workflow_id,
CAST(NULL AS #{ActiveRecord::Base.connection.type_to_sql(:integer)}) AS major_version,
CAST(NULL AS #{ActiveRecord::Base.connection.type_to_sql(:integer)}) AS minor_version,
CAST(NULL AS #{ActiveRecord::Base.connection.type_to_sql(:integer)}) AS workflow,
CAST(NULL AS #{ActiveRecord::Base.connection.type_to_sql(:integer)}) AS workflow_id,
'' AS firstname,
'' AS lastname,
CAST(NULL AS #{ActiveRecord::Base.connection.type_to_sql(:decimal)}) AS author,
CAST(NULL AS #{ActiveRecord::Base.connection.type_to_sql(:integer)}) AS author,
'project' AS type,
CAST(0 AS #{ActiveRecord::Base.connection.type_to_sql(:decimal)}) AS deleted,
CAST(0 AS #{ActiveRecord::Base.connection.type_to_sql(:integer)}) AS deleted,
0 AS sort #{cf_columns}}).visible
if dmsf_folder_id || deleted
scope.none
@ -230,15 +230,15 @@ class DmsfQuery < Query
scope = DmsfFolder.select(%{
dmsf_folders.id AS id,
dmsf_folders.project_id AS project_id,
CAST(NULL AS #{ActiveRecord::Base.connection.type_to_sql(:decimal)}) AS revision_id,
CAST(NULL AS #{ActiveRecord::Base.connection.type_to_sql(:integer)}) AS revision_id,
dmsf_folders.title AS title,
NULL AS filename,
CAST(NULL AS #{ActiveRecord::Base.connection.type_to_sql(:decimal)}) AS size,
CAST(NULL AS #{ActiveRecord::Base.connection.type_to_sql(:integer)}) AS size,
dmsf_folders.updated_at AS updated,
CAST(NULL AS #{ActiveRecord::Base.connection.type_to_sql(:decimal)}) AS major_version,
CAST(NULL AS #{ActiveRecord::Base.connection.type_to_sql(:decimal)}) AS minor_version,
CAST(NULL AS #{ActiveRecord::Base.connection.type_to_sql(:decimal)}) AS workflow,
CAST(NULL AS #{ActiveRecord::Base.connection.type_to_sql(:decimal)}) AS workflow_id,
CAST(NULL AS #{ActiveRecord::Base.connection.type_to_sql(:integer)}) AS major_version,
CAST(NULL AS #{ActiveRecord::Base.connection.type_to_sql(:integer)}) AS minor_version,
CAST(NULL AS #{ActiveRecord::Base.connection.type_to_sql(:integer)}) AS workflow,
CAST(NULL AS #{ActiveRecord::Base.connection.type_to_sql(:integer)}) AS workflow_id,
users.firstname AS firstname,
users.lastname AS lastname,
users.id AS author,
@ -275,12 +275,12 @@ class DmsfQuery < Query
dmsf_links.target_id AS revision_id,
dmsf_links.name AS title,
dmsf_folders.title AS filename,
CAST(NULL AS #{ActiveRecord::Base.connection.type_to_sql(:decimal)}) AS size,
CAST(NULL AS #{ActiveRecord::Base.connection.type_to_sql(:integer)}) AS size,
COALESCE(dmsf_folders.updated_at, dmsf_links.updated_at) AS updated,
CAST(NULL AS #{ActiveRecord::Base.connection.type_to_sql(:decimal)}) AS major_version,
CAST(NULL AS #{ActiveRecord::Base.connection.type_to_sql(:decimal)}) AS minor_version,
CAST(NULL AS #{ActiveRecord::Base.connection.type_to_sql(:decimal)}) AS workflow,
CAST(NULL AS #{ActiveRecord::Base.connection.type_to_sql(:decimal)}) AS workflow_id,
CAST(NULL AS #{ActiveRecord::Base.connection.type_to_sql(:integer)}) AS major_version,
CAST(NULL AS #{ActiveRecord::Base.connection.type_to_sql(:integer)}) AS minor_version,
CAST(NULL AS #{ActiveRecord::Base.connection.type_to_sql(:integer)}) AS workflow,
CAST(NULL AS #{ActiveRecord::Base.connection.type_to_sql(:integer)}) AS workflow_id,
users.firstname AS firstname,
users.lastname AS lastname,
users.id AS author,
@ -387,15 +387,15 @@ class DmsfQuery < Query
scope = DmsfLink.select(%{
dmsf_links.id AS id,
dmsf_links.project_id AS project_id,
CAST(NULL AS #{ActiveRecord::Base.connection.type_to_sql(:decimal)}) AS revision_id,
CAST(NULL AS #{ActiveRecord::Base.connection.type_to_sql(:integer)}) AS revision_id,
dmsf_links.name AS title,
dmsf_links.external_url AS filename,
CAST(NULL AS #{ActiveRecord::Base.connection.type_to_sql(:decimal)}) AS size,
CAST(NULL AS #{ActiveRecord::Base.connection.type_to_sql(:integer)}) AS size,
dmsf_links.updated_at AS updated,
CAST(NULL AS #{ActiveRecord::Base.connection.type_to_sql(:decimal)}) AS major_version,
CAST(NULL AS #{ActiveRecord::Base.connection.type_to_sql(:decimal)}) AS minor_version,
CAST(NULL AS #{ActiveRecord::Base.connection.type_to_sql(:decimal)}) AS workflow,
CAST(NULL AS #{ActiveRecord::Base.connection.type_to_sql(:decimal)}) AS workflow_id,
CAST(NULL AS #{ActiveRecord::Base.connection.type_to_sql(:integer)}) AS major_version,
CAST(NULL AS #{ActiveRecord::Base.connection.type_to_sql(:integer)}) AS minor_version,
CAST(NULL AS #{ActiveRecord::Base.connection.type_to_sql(:integer)}) AS workflow,
CAST(NULL AS #{ActiveRecord::Base.connection.type_to_sql(:integer)}) AS workflow_id,
users.firstname AS firstname,
users.lastname AS lastname,
users.id AS author,