Closed deahhh closed 10 months ago
Thanks - what's the code that generates this error?
Thanks - what's the code that generates this error?
model:
module Articles
import SearchLight: AbstractModel, DbId, save!
import Base: @kwdef, convert
export Article
@kwdef mutable struct Article <: AbstractModel
id::DbId = DbId()
kw::Vector{String} = []
end
Base.convert(::Type{Vector{String}}, v::String) =
map(x->x.captures[1]|>String, eachmatch(r"E'(.*?)'", v))
end
migration:
module CreateTableArticles
import SearchLight.Migrations: create_table, column, columns, pk, add_index, drop_table, add_indices
function up()
create_table(:articles) do
[
pk()
column(:kw, :string, "[]", limit=16)
]
end
end
function down()
drop_table(:articles)
end
end
test code:
using Ehl.Articles
using Ehl.Articles:*
Article(kw=["hello"]) |> save!
Article(kw=["good", "bye"]) |> save!
Thanks!
Could you teach me how to store tsvector
typed value?
And how to store json
type?
As they are not in the dictionary named TYPE_MAPPINGS
in file SearchLightPostgreSQL.jl
.
ENV:
I've debugged: by replaced model_types.jl#119
SQLInput(a::Vector{T}) where {T} = SQLInput.(a)
withSQLInput(a::Vector{T}) where {T} = SQLInput("{"*join(SQLInput.(a), ",")*"}")
please check model_types.jl#140
convert(::Type{SQLInput}, r::Real) = SQLInput(parse(r))
too.