sqltree_schema 0.4.1+1

  • Example
  • Installing
  • Versions
  • 0

example/sqltree_schema_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;

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

import 'users_schema.g.dart' as schema;

final schema.USERSDB_Schema DEFAULT_SCHEMA = schema.createUSERSDB_Schema("");
final schema.USERSDB_Schema OTHER_SCHEMA = schema.createUSERSDB_Schema("OTHER");

main() {
  var select2 = sql.select(schema.USERS.ID)
    ..from(sql.setReference("USERS", schema.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();

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

  print(sql.prettify(sql.format(
      sql.select(schema.USERS.ID, schema.USERS.columns)..from(schema.USERS))));

  print(sql.prettify(sql.format(sql.select(schema.USERS.columns)
    ..from(schema.USERS)
    ..where(schema.USERS.columns.pks.equalParameter))));

  schema.USERS.columns.pks.equalParameter;

  print(sql.prettify(sql.format(sql.insert(schema.USERS)
    ..columns(schema.USERS.columns.details)
    ..values(sql.tuple(schema.USERS.columns.details.parameter)))));

  print(sql.prettify(sql.format(sql.update(schema.USERS)
    ..set(schema.USERS.columns.details.equalParameter)
    ..where(schema.USERS.columns.pks.equalParameter))));

  print(sql.prettify(sql.format(sql.delete(schema.USERS)
    ..where(schema.USERS.columns.pks.equalParameter))));

  print(sql.prettify(sql.format(sql.select(
      schema.USERS.columns.exclude(schema.USERS.ID, schema.USERS.GROUP_ID)))));

  print(sql.prettify(sql.format(sql.select(
      schema.USERS.ID,
      schema.USERS.ID.as,
      schema.USERS.ID.alias("MY_ID"),
      schema.USERS.ID.alias("MY_ID").as,
      schema.USERS.alias("MY_USERS").ID,
      schema.USERS.alias("MY_USERS").ID.as,
      schema.USERS.alias("MY_USERS").ID.alias("MY_ID"),
      schema.USERS.alias("MY_USERS").ID.alias("MY_ID").as)
    ..from(schema.USERS, schema.USERS.as, schema.USERS.alias("MY_USERS"),
        schema.USERS.alias("MY_USERS").as))));

  print("******************************");
  var select = sql.select(schema.USERS.ID)
    ..from(sql.setReference("USERS", schema.USERS));

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

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

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

  print(schema.USERS.ID.isFreezed);

  select = sql.select(
      schema.USERS.ID,
      schema.USERS.ID.alias("MY_ID"),
      schema.USERS.alias("MY_USERS").ID,
      schema.USERS.alias("MY_USERS").ID.alias("MY_ID"))
    ..from(schema.USERS, schema.USERS.as, schema.USERS.alias("MY_USERS"),
        schema.USERS.alias("MY_USERS").as);

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

  var i = 0;
  print(select.selectClause.children[i].isFreezed);

  print(sql.prettify(sql.format(schema.USERS.alias("MY_USERS").as)));
  print(sql.prettify(sql.format(schema.USERS.ID.alias("MY_ID").as)));
  print(sql.prettify(sql.format(schema.USERS.as)));
  print(sql.prettify(sql.format(schema.USERS.ID.as)));

  print("******************************++++++++++");
  print(sql.format(DEFAULT_SCHEMA));
  print(sql.format(DEFAULT_SCHEMA.USERS));
  print(sql.format(DEFAULT_SCHEMA.USERS.as));
  print(sql.format(DEFAULT_SCHEMA.USERS.alias("MY_USERS")));
  print(sql.format(DEFAULT_SCHEMA.USERS.alias("MY_USERS").as));
  print(sql.format(OTHER_SCHEMA));
  print(sql.format(OTHER_SCHEMA.USERS));
  print(sql.format(OTHER_SCHEMA.USERS.as));
  print(sql.format(OTHER_SCHEMA.USERS.alias("MY_USERS")));
  print(sql.format(OTHER_SCHEMA.USERS.alias("MY_USERS").as));
  print("******************************");
  print(sql.format(DEFAULT_SCHEMA.USERS.ID));
  print(sql.format(DEFAULT_SCHEMA.USERS.ID.as));
  print(sql.format(DEFAULT_SCHEMA.USERS.ID.alias("MY_ID")));
  print(sql.format(DEFAULT_SCHEMA.USERS.ID.alias("MY_ID").as));
  print(sql.format(DEFAULT_SCHEMA.USERS.alias("MY_USERS").ID));
  print(sql.format(DEFAULT_SCHEMA.USERS.alias("MY_USERS").ID.as));
  print(sql.format(DEFAULT_SCHEMA.USERS.alias("MY_USERS").ID.alias("MY_ID")));
  print(
      sql.format(DEFAULT_SCHEMA.USERS.alias("MY_USERS").ID.alias("MY_ID").as));
  print(sql.format(OTHER_SCHEMA.USERS.ID));
  print(sql.format(OTHER_SCHEMA.USERS.ID.as));
  print(sql.format(OTHER_SCHEMA.USERS.ID.alias("MY_ID")));
  print(sql.format(OTHER_SCHEMA.USERS.ID.alias("MY_ID").as));
  print(sql.format(OTHER_SCHEMA.USERS.alias("MY_USERS").ID));
  print(sql.format(OTHER_SCHEMA.USERS.alias("MY_USERS").ID.as));
  print(sql.format(OTHER_SCHEMA.USERS.alias("MY_USERS").ID.alias("MY_ID")));
  print(sql.format(OTHER_SCHEMA.USERS.alias("MY_USERS").ID.alias("MY_ID").as));
  print("******************************");
  print(sql.format(OTHER_SCHEMA.USERS));
  print(sql.format(OTHER_SCHEMA.USERS.as));
  print(sql.format(OTHER_SCHEMA.USERS.alias("MY_USERS")));
  print(sql.format(OTHER_SCHEMA.USERS.alias("MY_USERS").as));
  print("******************************");
  print(sql.format(sql.select(schema.USERS.columns)));
  print(sql.format(sql.select(schema.USERS.columns.unqualified)));
  print(sql.format(sql.select(
      sql.column(schema.USERS.ID, schema.USERS.ABSTRACT, schema.USERS.BODY))));
  print(sql.format(sql.select(sql
      .column(schema.USERS.ID, schema.USERS.ABSTRACT, schema.USERS.BODY)
      .unqualified)));
  print("******************************");
  print(sql.prettify(sql.format(sql.insert(schema.USERS)
    ..set(sql
        .column(schema.USERS.ID, schema.USERS.ABSTRACT, schema.USERS.BODY)
        .equalParameter))));
}

Use this package as a library

1. Depend on it

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


dependencies:
  sqltree_schema: ^0.4.1+1

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_schema/sqltree_schema.dart';
  
Version Uploaded Documentation Archive
0.4.1+1 Dec 13, 2016 Go to the documentation of sqltree_schema 0.4.1+1 Download sqltree_schema 0.4.1+1 archive
0.4.1 Dec 13, 2016 Go to the documentation of sqltree_schema 0.4.1 Download sqltree_schema 0.4.1 archive
0.4.0+1 Dec 6, 2016 Go to the documentation of sqltree_schema 0.4.0+1 Download sqltree_schema 0.4.0+1 archive
0.4.0 Jul 20, 2016 Go to the documentation of sqltree_schema 0.4.0 Download sqltree_schema 0.4.0 archive
0.3.0 Jul 11, 2016 Go to the documentation of sqltree_schema 0.3.0 Download sqltree_schema 0.3.0 archive
0.2.0 Jun 21, 2016 Go to the documentation of sqltree_schema 0.2.0 Download sqltree_schema 0.2.0 archive
0.1.0 Jun 14, 2016 Go to the documentation of sqltree_schema 0.1.0 Download sqltree_schema 0.1.0 archive
0.0.1+1 Jun 14, 2016 Go to the documentation of sqltree_schema 0.0.1+1 Download sqltree_schema 0.0.1+1 archive
0.0.1 Jun 14, 2016 Go to the documentation of sqltree_schema 0.0.1 Download sqltree_schema 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