test:one(a
, b: 0
, c: 0
, d)

$x = 
'{ "tables": {
    "comment": "",
    "columns": {
        "id": {
            "comment": "day id",
            "data_type": "bigint(20) unsigned",
            "charset": null,
            "collation": null,
            "nullable?": false,
            "default": null,
            "extra": "auto_increment",
            "uuid": "6ab13677-cbfe-41a1-b37d-bc1c240d808b"
        },
        "name": {
            "comment": "",
            "data_type": "varchar(255)",
            "charset": "utf8mb4",
            "collation": "utf8mb4_general_ci",
            "nullable?": false,
            "default": "",
            "extra": "",
            "uuid": "3a0f7312-8f7c-44b9-b047-76e2107a306a"
        }
    },
    "indexes": {
        "PRIMARY": {
            "columns": [
                "6ab13677-cbfe-41a1-b37d-bc1c240d808b"
            ],
            "type": "BTREE",
            "unique?": true,
            "uuid": "5fa26d97-fc36-4103-b219-89b3a4f80822"
        },
        "id": {
            "columns": [
                "6ab13677-cbfe-41a1-b37d-bc1c240d808b"
            ],
            "type": "BTREE",
            "unique?": true,
            "uuid": "4b345ebb-8bcf-420e-807e-8727b900c7c5"
        }
    },
    "uuid": "686cf82c-39db-4585-bf9d-59bd39c129cb"
}}';

$x = json:decode($x)
// $columns = $x['columuns']

sql:get_all_defined_columns($x)
#=> [
#=>     "6ab13677-cbfe-41a1-b37d-bc1c240d808b" => [
#=>         "column_name" => "id",
#=>         "comment" => "day id",
#=>         "data_type" => "bigint(20) unsigned",
#=>         "charset" => NULL,
#=>         "collation" => NULL,
#=>         "nullable?" => FALSE,
#=>         "default" => NULL,
#=>         "extra" => "auto_increment",
#=>         "uuid" => "6ab13677-cbfe-41a1-b37d-bc1c240d808b",
#=>         "indexes" => [
#=>             "PRIMARY" => "5fa26d97-fc36-4103-b219-89b3a4f80822",
#=>             "id" => "4b345ebb-8bcf-420e-807e-8727b900c7c5"
#=>         ],
#=>         "foreign_keys" => [
#=>             "as_column" => [],
#=>             "as_referenced_column" => []
#=>         ],
#=>         "table_name" => "tables",
#=>         "table_uuid" => "686cf82c-39db-4585-bf9d-59bd39c129cb",
#=>         "table_comment" => ""
#=>     ],
#=>     "3a0f7312-8f7c-44b9-b047-76e2107a306a" => [
#=>         "column_name" => "name",
#=>         "comment" => "",
#=>         "data_type" => "varchar(255)",
#=>         "charset" => "utf8mb4",
#=>         "collation" => "utf8mb4_general_ci",
#=>         "nullable?" => FALSE,
#=>         "default" => "",
#=>         "extra" => "",
#=>         "uuid" => "3a0f7312-8f7c-44b9-b047-76e2107a306a",
#=>         "indexes" => [],
#=>         "foreign_keys" => [
#=>             "as_column" => [],
#=>             "as_referenced_column" => []
#=>         ],
#=>         "table_name" => "tables",
#=>         "table_uuid" => "686cf82c-39db-4585-bf9d-59bd39c129cb",
#=>         "table_comment" => ""
#=>     ]
#=> ]


sql:get_committed_table_structure(98842687618943461, 'day')
#=> [
#=>     "table_name" => "day",
#=>     "columns" => [
#=>         "6ab13677-cbfe-41a1-b37d-bc1c240d808b" => [
#=>             "column_name" => "id",
#=>             "data_type" => "bigint(20) unsigned",
#=>             "charset" => NULL,
#=>             "collation" => NULL,
#=>             "nullable?" => FALSE,
#=>             "default" => FALSE,
#=>             "extra" => "auto_increment",
#=>             "comment" => "day id",
#=>             "uuid" => "6ab13677-cbfe-41a1-b37d-bc1c240d808b",
#=>             "indexes" => [
#=>                 "id" => "4b345ebb-8bcf-420e-807e-8727b900c7c5",
#=>                 "PRIMARY" => "5fa26d97-fc36-4103-b219-89b3a4f80822"
#=>             ],
#=>             "foreign_keys" => [
#=>                 "as_column" => [],
#=>                 "as_referenced_column" => []
#=>             ],
#=>             "table_name" => "day",
#=>             "table_uuid" => "686cf82c-39db-4585-bf9d-59bd39c129cb",
#=>             "table_comment" => ""
#=>         ],
#=>         "3a0f7312-8f7c-44b9-b047-76e2107a306a" => [
#=>             "column_name" => "name",
#=>             "data_type" => "varchar(255)",
#=>             "charset" => "utf8mb4",
#=>             "collation" => "utf8mb4_general_ci",
#=>             "nullable?" => FALSE,
#=>             "default" => "",
#=>             "extra" => "",
#=>             "comment" => "",
#=>             "uuid" => "3a0f7312-8f7c-44b9-b047-76e2107a306a",
#=>             "indexes" => [],
#=>             "foreign_keys" => [
#=>                 "as_column" => [],
#=>                 "as_referenced_column" => []
#=>             ],
#=>             "table_name" => "day",
#=>             "table_uuid" => "686cf82c-39db-4585-bf9d-59bd39c129cb",
#=>             "table_comment" => ""
#=>         ]
#=>     ],
#=>     "indexes" => [
#=>         "4b345ebb-8bcf-420e-807e-8727b900c7c5" => [
#=>             "index_name" => "id",
#=>             "comment" => "",
#=>             "columns" => [
#=>                 "id" => "6ab13677-cbfe-41a1-b37d-bc1c240d808b"
#=>             ],
#=>             "type" => "BTREE",
#=>             "unique?" => TRUE,
#=>             "uuid" => "4b345ebb-8bcf-420e-807e-8727b900c7c5",
#=>             "table_name" => "day",
#=>             "table_uuid" => "686cf82c-39db-4585-bf9d-59bd39c129cb",
#=>             "table_comment" => ""
#=>         ],
#=>         "5fa26d97-fc36-4103-b219-89b3a4f80822" => [
#=>             "index_name" => "PRIMARY",
#=>             "comment" => "",
#=>             "columns" => [
#=>                 "id" => "6ab13677-cbfe-41a1-b37d-bc1c240d808b"
#=>             ],
#=>             "type" => "BTREE",
#=>             "unique?" => TRUE,
#=>             "uuid" => "5fa26d97-fc36-4103-b219-89b3a4f80822",
#=>             "table_name" => "day",
#=>             "table_uuid" => "686cf82c-39db-4585-bf9d-59bd39c129cb",
#=>             "table_comment" => ""
#=>         ]
#=>     ],
#=>     "foreign_keys" => [],
#=>     "comment" => "",
#=>     "uuid" => "686cf82c-39db-4585-bf9d-59bd39c129cb"
#=> ]

string:to_camel_case(string: 'hi_there')
#=> "hiThere"

Copyright ©2013-2022 SunSed®. All rights reserved.