Exemple #1
0
    def testFixDdl(self):
        ddl_strings = [
            'CREATE TABLE MyTable;',
            'CREATE TABLE anotherTable;CREATE TABLE oneMoreTable'
        ]

        self.assertEqual([
            'CREATE TABLE MyTable', 'CREATE TABLE anotherTable',
            'CREATE TABLE oneMoreTable'
        ], flags.SplitDdlIntoStatements(ddl_strings))
Exemple #2
0
    def Run(self, args):
        """This is what gets called when the user runs this command.

    Args:
      args: an argparse namespace. All the arguments that were provided to this
        command invocation.

    Returns:
      Some value that we want to have printed later.
    """
        op = databases.UpdateDdl(args.CONCEPTS.database.Parse(),
                                 flags.SplitDdlIntoStatements(args.ddl or []))
        if args. async:
            return op
        return database_operations.Await(op, 'DDL updating')
    def _CreateDatabase(self, database, schema):
        """Create the sample database.

    Args:
      database: String. The database name.
      schema: String. The schema used for the sample database.

    Returns:
      Get Request from the Await operation.
    """

        op = databases.Create(self._instance, database,
                              flags.SplitDdlIntoStatements([schema]))

        return database_operations.Await(op, 'Creating sample database')
  def Run(self, args):
    """This is what gets called when the user runs this command.

    Args:
      args: an argparse namespace. All the arguments that were provided to this
        command invocation.

    Returns:
      Some value that we want to have printed later.
    """
    op = databases.UpdateDdl(args.CONCEPTS.database.Parse(),
                             flags.SplitDdlIntoStatements(args.ddl or []))
    if args.async_:
      return log.status.Print(
          'Schema update in progress. Operation name={}'.format(op.name))
    return database_operations.Await(op, 'Schema updating')
Exemple #5
0
    def Run(self, args):
        """This is what gets called when the user runs this command.

    Args:
      args: an argparse namespace. All the arguments that were provided to this
        command invocation.

    Returns:
      Some value that we want to have printed later.
    """
        database_ref = args.CONCEPTS.database.Parse()
        instance_ref = database_ref.Parent()
        op = databases.Create(instance_ref, args.database,
                              flags.SplitDdlIntoStatements(args))
        if args.async_:
            return op
        return database_operations.Await(op, 'Creating database')
Exemple #6
0
    def testFixDdl(self):
        ddl_strings = [
            'CREATE TABLE MyTable;',
            'CREATE TABLE anotherTable;CREATE TABLE oneMoreTable',
            '--this is a test table\nCREATE TABLE T4;',
            'CREATE TABLE T5(\n--comment \n);CREATE T6--this is a test table\n',
            'CREATE--comment with no newline',
        ]

        self.assertEqual([
            'CREATE TABLE MyTable',
            'CREATE TABLE anotherTable',
            'CREATE TABLE oneMoreTable',
            '\nCREATE TABLE T4',
            'CREATE TABLE T5(\n\n)',
            'CREATE T6\n',
            'CREATE',
        ], flags.SplitDdlIntoStatements(self.MakeArgs(ddls=ddl_strings)))
Exemple #7
0
 def testFixDdlFile(self):
     ddl_file = self.Touch(self.temp_path, contents='CREATE T1')
     self.assertEqual(
         flags.SplitDdlIntoStatements(
             self.MakeArgs(ddls='CREATE T2', ddl_file=ddl_file)),
         ['CREATE T1'])