note
Anonymous Monk
<p> After reading this thread immediately thought of [mod://sqlt], looked inside, no premade thing :) so off to search I went
<readmore>
<br> aww, zip [href://http://search.cpan.org/grep?cpanid=FREW&release=SQL-Translator-0.11018&string=guess&i=1&n=1&C=0]
<br> aww, 3 unrelated [href://http://search.cpan.org/grep?cpanid=FREW&release=SQL-Translator-0.11018&string=best&i=1&n=1&C=4]
<p> Although these two caught my eye [mod://SQL::Translator::Parser::JSON], [mod://SQL::Translator::Schema::Field]
<p> Then I switched to searching within [cpan://sql guess type], [cpan://sql best type], [cpan://sql match type]
<p> Found [mod://DBD::mysql::AutoTypes] -- automatically assign parameters' sql type to support old DBD::mysql functionality
<p> found inside <c>
/^$RE{num}{int}$/ ? DBI::SQL_INTEGER :
/^$RE{num}{real}$/ ? DBI::SQL_DOUBLE :
</c>
<p> then found
<p> [href://https://metacpan.org/pod/DBI#sql_type_cast]
<c> $sts = DBI::sql_type_cast($sv, $sql_type, $flags); </c> sql_type_cast attempts to cast $sv to the SQL type
<p> Looking inside [mod://SQL::Translator::Schema::Field] I see the same thing <c>use DBI qw(:sql_types);
# Mapping from string to sql constant
our %type_mapping = (
integer => SQL_INTEGER,
int => SQL_INTEGER,</c>
<p> Food for thought I guess :)
</readmore>
<p> So my one idea (best of the bunch) is to stick it in SQL::Translator::Parser::GuessBestCastTypeMatchPerl
, base it on [mod://SQL::Translator::Parser::JSON], make it take either perl ref or perl string to [id://1037072|safe undumper] :) ... so that illegal field names are [mod://SQL::Translator::Producer] problem (not yours)
<p> Another is Data::InferBestGuessSQLSchemaType but pause says [href://http://pause.perl.org/pause/query?ACTION=pause_namingmodules#NAMES_TO_AVOID|Avoid the too-general nouns like Devel, Sys, Text, Data]
<p> ?? Send a patch to stick it inside [mod://Type::Utils] making sure that all the keywords are represented in the docs for search purposes, but Type doesn't feel better than Data -- but yeah, patches are hassles :)
<p> So maybe [mod://SQL::Abstract]::InferSchemaTypesByBestMatchGuessFromPerlData :)
<p> I definitely feel sql/schema/type/infer ought to be in the name some how, and the all the keywords in the <c> =head1 NAME ... NAME - Perl extension ... </c>
1081705
1081705
20