GenieFramework / SearchLight.jl

ORM layer for Genie.jl, the highly productive Julia web framework
https://genieframework.com
MIT License
139 stars 16 forks source link

Error occur when using create_table #76

Closed FrederikRein closed 10 months ago

FrederikRein commented 10 months ago

Describe the bug I am fairly new to SearchLight so I don't really have a clue what happens in the error. I am connected to an PGAdmin local db.

The bug occurs currently in my DDL file for setting up my Database. I have a function up() which I execute. In there are a bunch of create_table() do .... end statements. I don´t really understand why the error occurs. Therefore let me explain.

(some tables follow the same structure) I managed to fix some statements. I copied segments of working tables and replaced these segments in tables where the error occured. Than it works fine. I compared the before and after of the code in VSC and it didn´t show me any differences.

There are still tables which don't follow the same structure so I can't use that way of fixing anymore. I tried rewriting the code but it didn't work ether.

Error stacktrace

ERROR: KeyError: key :String not found Stacktrace: [1] getindex(h::Dict{Symbol, Symbol}, key::Symbol) @ Base .\dict.jl:484 [2] column(name::Symbol, column_type::Symbol, options::String; default::Nothing, limit::Nothing, not_null::Bool) @ SearchLightPostgreSQL C:\Users\rein_fr.julia\packages\SearchLightPostgreSQL\8KdWH\src\SearchLightPostgreSQL.jl:325 [3] column @ C:\Users\rein_fr.julia\packages\SearchLightPostgreSQL\8KdWH\src\SearchLightPostgreSQL.jl:324 [inlined] [4] (::Main.AtraDDL.var"#1#56")() @ Main.AtraDDL c:\Users\rein_fr\Documents\temp.vsc\BitemporalPostgres\src\AtraDDL.jl:198 [5] create_table_sql(f::Main.AtraDDL.var"#1#56", name::String, options::String) @ SearchLightPostgreSQL C:\Users\rein_fr.julia\packages\SearchLightPostgreSQL\8KdWH\src\SearchLightPostgreSQL.jl:320 [6] create_table (repeats 2 times) @ C:\Users\rein_fr.julia\packages\SearchLightPostgreSQL\8KdWH\src\SearchLightPostgreSQL.jl:313 [inlined] [7] up() @ Main.AtraDDL c:\Users\rein_fr\Documents\temp.vsc\BitemporalPostgres\src\AtraDDL.jl:197 [8] top-level scope @ REPL[2]:1

To reproduce The Error still occurs at tables like:

create_table(:organizations) do
    [
        column(:id, :bigserial, "PRIMARY KEY")
        column(:acronym, :String, "NOT NULL DEFAULT \'still testing\'")
    ]
end

create_table(:Tlb) do
    [
        column(:id, :bigserial, "PRIMARY KEY")
        column(:refNum, :String, "UNIQUE NOT NULL")
    ]
end

create_table(:acType) do
    [
        column(:id, :bigserial, "PRIMARY KEY")
        column(:type, :String, "UNIQUE NOT NULL")
    ]
end

Expected behavior Tables created in the Database I'm connected to.

Additional context julia> AtraDDL.up()

FrederikRein commented 10 months ago

I am an complete Idiot. I should learn to read. Searchlight doesn´t understand :String but needs :string as parameter.