Title: default value conversion should support strings · Issue #325 · hyperstack-org/hyperstack · GitHub
Open Graph Title: default value conversion should support strings · Issue #325 · hyperstack-org/hyperstack
X Title: default value conversion should support strings · Issue #325 · hyperstack-org/hyperstack
Description: It is legal in the rails schema to say t.decimal "total_cost_of_failure", precision: 10, scale: 2, default: "0.0", null: false for example. In this case default value of '0.0' should be converted to the number 0.0. This applies to decima...
Open Graph Description: It is legal in the rails schema to say t.decimal "total_cost_of_failure", precision: 10, scale: 2, default: "0.0", null: false for example. In this case default value of '0.0' should be converted t...
X Description: It is legal in the rails schema to say t.decimal "total_cost_of_failure", precision: 10, scale: 2, default: "0.0", null: false for example. In this case default value of '0....
Opengraph URL: https://github.com/hyperstack-org/hyperstack/issues/325
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"default value conversion should support strings","articleBody":"It is legal in the rails schema to say \r\n```ruby\r\nt.decimal \"total_cost_of_failure\", precision: 10, scale: 2, default: \"0.0\", null: false\r\n```\r\nfor example. In this case default value of '0.0' should be converted to the number 0.0.\r\n\r\nThis applies to decimals, floats, integers, and booleans.\r\n\r\nCurrently the code just returns the default value without conversion (if it happens to be a string)\r\n\r\nThis is the patch needed to accomplish this:\r\n\r\n```ruby\r\nmodule ReactiveRecord\r\n class Base\r\n class DummyValue \u003c BasicObject\r\n def build_default_value_for_float\r\n return Float(0.0) unless @column_hash[:default]\r\n\r\n @column_hash[:default].to_f\r\n end\r\n\r\n alias build_default_value_for_decimal build_default_value_for_float\r\n\r\n def build_default_value_for_integer\r\n return Integer(0) unless @column_hash[:default]\r\n\r\n @column_hash[:default].to_i\r\n end\r\n\r\n alias build_default_value_for_bigint build_default_value_for_integer\r\n\r\n def build_default_value_for_boolean\r\n return false unless @column_hash[:default]\r\n\r\n ![false, 0, \"0\", \"f\", \"F\", \"false\", \"FALSE\", \"off\", \"OFF\"].include?(@column_hash[:default])\r\n end\r\n end\r\n end\r\nend\r\n```","author":{"url":"https://github.com/catmando","@type":"Person","name":"catmando"},"datePublished":"2020-11-16T17:19:26.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/325/hyperstack/issues/325"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:4c1fef4d-e633-fbdb-b208-af1f1fabe8e3 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 83A6:1113DB:C6B8E5:FAE535:699183B1 |
| html-safe-nonce | 980f8b8d513369348c0ff8c2de9dd82dab9cbae9a6723b2941479880cd381c02 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4M0E2OjExMTNEQjpDNkI4RTU6RkFFNTM1OjY5OTE4M0IxIiwidmlzaXRvcl9pZCI6IjY1NDIzMTY0Njg3NzU3ODEyOTciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | ea41890eee1fbb6a5ab1da462df4f860c88ed19730bcd3fe708c2379eb1372cb |
| hovercard-subject-tag | issue:744017383 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/hyperstack-org/hyperstack/325/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b197e4c0a0533dd1eb6dac5f38c5cfa1331a9fb92cc016ed90ff768fdd95a4cc/hyperstack-org/hyperstack/issues/325 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b197e4c0a0533dd1eb6dac5f38c5cfa1331a9fb92cc016ed90ff768fdd95a4cc/hyperstack-org/hyperstack/issues/325 |
| og:image:alt | It is legal in the rails schema to say t.decimal "total_cost_of_failure", precision: 10, scale: 2, default: "0.0", null: false for example. In this case default value of '0.0' should be converted t... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | catmando |
| hostname | github.com |
| expected-hostname | github.com |
| None | 42c603b9d642c4a9065a51770f75e5e27132fef0e858607f5c9cb7e422831a7b |
| turbo-cache-control | no-preview |
| go-import | github.com/hyperstack-org/hyperstack git https://github.com/hyperstack-org/hyperstack.git |
| octolytics-dimension-user_id | 34562730 |
| octolytics-dimension-user_login | hyperstack-org |
| octolytics-dimension-repository_id | 145879576 |
| octolytics-dimension-repository_nwo | hyperstack-org/hyperstack |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 145879576 |
| octolytics-dimension-repository_network_root_nwo | hyperstack-org/hyperstack |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 848bc6032dcc93a9a7301dcc3f379a72ba13b96e |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width