generated from tpl/purs
Use Tuple in favor of ×
This commit is contained in:
parent
8d7af01288
commit
c759418c67
@ -23,7 +23,7 @@ purspgpp will replace this by something like the following:
|
||||
SELECT first_name, last_name
|
||||
FROM users
|
||||
WHERE id = $1
|
||||
""" :: Query (UUID × Unit) (String × String × Unit))
|
||||
""" :: Query (Tuple UUID Unit) (Tuple String (Tuple String Unit))
|
||||
```
|
||||
|
||||
You can integrate purspgpp into your build system. For example, here is a
|
||||
|
9
purspgpp
9
purspgpp
@ -72,10 +72,13 @@ sub process-module(libpq::Connection $conn, %mapping, Str:D $segment --> Str:D)
|
||||
multi sub process-query(libpq::Connection:D $conn, %mapping, Str:D $source --> Str:D) {
|
||||
$conn.prepare: '', $source;
|
||||
my $description = $conn.describe-prepared('');
|
||||
sub convert-types(@oids) {
|
||||
sub convert-types(Int:D @oids --> Str:D) {
|
||||
die "unknown oid: $_" unless %mapping{$_}:exists for @oids;
|
||||
(|@oids.map({%mapping{$_}}), "Unit").join(" × ");
|
||||
};
|
||||
multi sub infix:<Tuple>() is assoc<right> { "Unit" }
|
||||
multi sub infix:<Tuple>(Str:D $a) { $a }
|
||||
multi sub infix:<Tuple>(Str:D $a, Str:D $b --> Str:D) { "Tuple ($a) ($b)" }
|
||||
[Tuple] |@oids.map({%mapping{$_}}), "Unit";
|
||||
}
|
||||
my $parameters = convert-types($description.parameters);
|
||||
my $fields = convert-types($description.fields);
|
||||
"(Query \"\"\"$source\"\"\" :: Query ($parameters) ($fields))";
|
||||
|
Loading…
Reference in New Issue
Block a user