Adam Kennedy wrote:
Yes, native positional support is still important.
positions make it very easy to do SQL math.
To express it in overly simplistic code
$foo = [ "a = ?", "foo" ];
$bar = [ "b = ?", "bar" ];
$baz = "$foo and $bar";
# $baz now is [ "a = ? and b = ?", "foo", "bar" ];
Bearing mind a situation with an arbitrary number and complexity of these sql fragments to be added together, doing this sort of thing using named placeholders would be a nightmare.

Interesting.  You are demonstrating reasons it is useful to deal with
SQL fragments in non-templated form.

In Tangram what you describe is written like this;

  my $table = $storage->remote("Table");
  my $foo = $table->{a} == "foo";
  my $bar = $table->{b} == "bar";
  my $baz = $foo & $bar;

$foo expresses "a = 'foo'", $bar "b = 'bar'", and baz
"a = 'foo' AND b = 'bar'".  Currently this is not done with placeholders.

--- Full demo script:

use Tangram;
use YAML;

my $schema = Tangram::Schema->new(Load <<YAML);
classes:
  MyTable:
    fields:
      string: [ a, b ]
YAML

my @dsn = (...);

# print the schema for informational purposes
Tangram::Relational->deploy($schema);

eval { Tangram::Relational->retreat($schema, @dsn); };
Tangram::Relational->deploy($schema, @dsn);
my $storage = Tangram::Storage->connect($schema, @dsn);

  my $table = $storage->remote("MyTable");
  my $foo = $table->{a} == "foo";
  my $bar = $table->{b} == "bar";
  my $baz = $foo & $bar;

print Dump { "1. foo" => $foo, "2. bar" => $bar, "3. baz" => $baz };


Reply via email to