sqltree 0.6.0

  • Example
  • Installing
  • Versions
  • 0

example/sqltree_example.dart

// Copyright (c) 2016, Roberto Tassi. All rights reserved. Use of this source code
// is governed by a BSD-style license that can be found in the LICENSE file.

import 'package:sqltree/sqltree.dart' as sql;

main() {
  var nodes3 = sql.node("USERS");

  var node3 = nodes3.single;
  node3.reference = "USERS";
  print(node3.reference);
  print(nodes3.single.reference);

  var nodes2 = sql.setReference("USERS", "USERS");
  print(nodes2.first.reference);

  var nodes = sql.node(sql.setReference("USERS", "USERS"));

  print(nodes);
  print(nodes.first.reference);

  sql
      .setReference("USERS", "USERS")
      .single
      .whereReference("USERS")
      .single
      .disable();

  var select2 = sql.select("USERS.ID")
    ..from(sql.setReference("USERS", "USERS"));

  // select2.fromClause.children.first.reference = "USERS";

  print(select2.fromClause.children.first.reference);

  print(sql.prettify(sql.format(select2)));

  print(select2.fromClause.children.first.reference);

  select2.whereReference("USERS").single.disable();

  sql.custom("ciao").clone();

  var select = sql.select("*")
    ..from(sql.joins("tabella"))
    ..where(sql.equal("a", sql.parameter("par1")))
    ..where(sql.setReference("ref1", sql.equal("b", sql.parameter("par2"))))
    ..where(sql.qualify("a", "1", "2", "3"))
    ..where(sql.setReference("ref2", sql.sqlInTuple("a")))
    ..where(sql.sqlIn("a", sql.setReference("ref3", sql.tuple())))
    ..where(sql.sqlInTuple("a"))
    ..limit(10)
    ..offset(200);

  select.whereClause.children.last.children.last.children
      .addAll(sql.text("OPEN", "CLOSED"));

  select.whereReference("ref1").single.disable();

  select
      .whereReference("ref2")
      .single
      .children
      .last
      .children
      .addAll(sql.text("OPEN", "CLOSED"));

  select
      .whereReference("ref3")
      .single
      .children
      .addAll(sql.text("OPEN", "CLOSED"));

  print(sql.prettify(sql.format(select)));

  var conversion = sql.convert(sql.format(select));

  print(sql.prettify(conversion.positionalParameterSql));
  print(conversion.positionalParameterNames);

  print(sql.prettify(sql.format(select.clone())));

  var cloned = select.clone();

  cloned.whereReference("ref1").single.disable();

  print(sql.prettify(sql.format(cloned)));

  // select.clone(freeze: true).getSingleNodeByReference("ref1").disable();
  // select.clone(freeze: true).clone().getSingleNodeByReference("ref1").disable();

  var freezed = select.clone(freeze: true).clone(freeze: false);

  freezed
      .whereReference("ref3")
      .single
      .children
      .addAll(sql.text("OPEN", "CLOSED"));

  print(sql.prettify(sql.format(freezed)));

  select = select.clone(freeze: false);

  print(select == select.clone(freeze: false));

  select = select.clone(freeze: true);

  print(select == select.clone(freeze: true));

  print(sql.prettify(sql.format(sql.text(r"ci'\'ao").single)));

  print(sql.prettify(
      sql.format(sql.select(sql.function("coalesce", "ID", "REF_ID")))));
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  sqltree: ^0.6.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:sqltree/sqltree.dart';
  
Version Uploaded Documentation Archive
0.6.0 Dec 13, 2016 Go to the documentation of sqltree 0.6.0 Download sqltree 0.6.0 archive
0.5.0 Dec 6, 2016 Go to the documentation of sqltree 0.5.0 Download sqltree 0.5.0 archive
0.4.0 Dec 6, 2016 Go to the documentation of sqltree 0.4.0 Download sqltree 0.4.0 archive
0.3.0 Jul 20, 2016 Go to the documentation of sqltree 0.3.0 Download sqltree 0.3.0 archive
0.2.0 Jul 11, 2016 Go to the documentation of sqltree 0.2.0 Download sqltree 0.2.0 archive
0.1.0 Jun 21, 2016 Go to the documentation of sqltree 0.1.0 Download sqltree 0.1.0 archive
0.0.1+1 Jun 14, 2016 Go to the documentation of sqltree 0.0.1+1 Download sqltree 0.0.1+1 archive
0.0.1 Jun 14, 2016 Go to the documentation of sqltree 0.0.1 Download sqltree 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
--
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
--
Overall:
Weighted score of the above. [more]
0
Learn more about scoring.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Analysis issues and suggestions

Support Dart 2 in pubspec.yaml.

The SDK constraint in pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see https://www.dartlang.org/dart-2#migration.

Maintenance issues and suggestions

Running dartdoc failed. (-10 points)

Make sure dartdoc runs without any issues.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.8.0 <2.0.0