Convert table references to full database/table names
This allows tables to be surrounded in braces, without specifying the database
429078
protected function tableNames(&$query)
    {
        $this->modifyQuery($query, function($part) {
            return preg_replace_callback("/{([^}]+)}/", function($match) {
                return $this->getTableName($match[1]);
            }, $part);
        });
    }
34279
def get_tables_for_bind(self, bind=None):
        """"""
        result = []
        tables = Model.metadata.tables
        for key in tables:
            if tables[key].info.get("bind_key") == bind:
                result.append(tables[key])
        return result
213215
public function setNameFromTable()
    {
        $fullName = '';
        $upperCase = true;
        for ($i = 0; $i < strlen($this->table); $i++) {
            $character = $this->table[$i];

            if ($character === '_') {
                $upperCase = true;
            } else {
                $fullName .= $upperCase ? strtoupper($character) : $character;
                $upperCase = false;
            }
        }

        if (substr($fullName, -3) === 'ies') {
            $fullName = substr($fullName, 0, -3) . 'y';
        } elseif (substr($fullName, -3) === 'ses') {
            $fullName = substr($fullName, 0, -3) . 's';
        } elseif (substr($fullName, -1) === 's') {
            $fullName = substr($fullName, 0, -1);
        }

        $this->name = $fullName;
        return $this;
    }
836335
def _encode_dbref(name, value, check_keys, opts):
    """"""
    buf = bytearray(b"\x03" + name + b"\x00\x00\x00\x00")
    begin = len(buf) - 4

    buf += _name_value_to_bson(b"$ref\x00",
                               value.collection, check_keys, opts)
    buf += _name_value_to_bson(b"$id\x00",
                               value.id, check_keys, opts)
    if value.database is not None:
        buf += _name_value_to_bson(
            b"$db\x00", value.database, check_keys, opts)
    for key, val in iteritems(value._DBRef__kwargs):
        buf += _element_to_bson(key, val, check_keys, opts)

    buf += b"\x00"
    buf[begin:begin + 4] = _PACK_INT(len(buf) - begin)
    return bytes(buf)
442454
def all_table_names_in_database(self, cache=False,
                                    cache_timeout=None, force=False):
        """"""
        if not self.allow_multi_schema_metadata_fetch:
            return []
        return self.db_engine_spec.fetch_result_sets(self, 'table')
656643
def table_absent(name, db):
    '''
    
    '''
    changes = {'name': name,
               'changes': {},
               'result': None,
               'comment': ''}
    conn = None
    try:
        conn = sqlite3.connect(db, detect_types=sqlite3.PARSE_DECLTYPES)
        tables = _query(conn, "SELECT sql FROM sqlite_master " +
                              " WHERE type='table' AND name=?", [name])

        if len(tables) == 1:
            if __opts__['test']:
                changes['result'] = True
                changes['comment'] = "'" + name + "' will be dropped"
            else:
                conn.execute("DROP TABLE " + name)
                conn.commit()
                changes['changes']['old'] = tables[0][0]
                changes['result'] = True
                changes['comment'] = "'" + name + "' was dropped"
        elif not tables:
            changes['result'] = True
            changes['comment'] = "'" + name + "' is already absent"
        else:
            changes['result'] = False
            changes['comment'] = "Multiple tables with the same name='" + \
                                 name + "'"

    except Exception as e:
        changes['result'] = False
        changes['comment'] = six.text_type(e)

    finally:
        if conn:
            conn.close()

    return changes
501549
def getsubtables(self):
        """"""
        keyset = self.getkeywords()
        names = []
        for key, value in keyset.items():
            if isinstance(value, str) and value.find('Table: ') == 0:
                names.append(_do_remove_prefix(value))
        return names
361951
def compiled_foreign_keys(self):
        """"""

        def get_column_args(column):
            tmp = []
            for arg_name, arg_val in column.items():
                if arg_name not in ('name', 'type', 'reference'):
                    if arg_name in ('server_default', 'server_onupdate'):
                        arg_val = '"{}"'.format(arg_val)
                    tmp.append(ALCHEMY_TEMPLATES.column_arg.safe_substitute(arg_name=arg_name,
                                                                            arg_val=arg_val))
            return ", ".join(tmp)

        def get_fkey_args(column):
            table = column['reference']['table']
            column = column['reference']['column']
            return ALCHEMY_TEMPLATES.foreign_key_arg.safe_substitute(reference_table=table, reference_column=column)

        res = []
        for column in self.foreign_key_definitions:
            column_args = get_column_args(column)
            column_type, type_params = ModelCompiler.get_col_type_info(column.get('type'))
            column_name = column.get('name')
            reference = get_fkey_args(column)
            if column_type in MUTABLE_DICT_TYPES:
                column_type = ALCHEMY_TEMPLATES.mutable_dict_type.safe_substitute(type=column_type,
                                                                                  type_params=type_params)
                type_params = ''
            res.append(
                ALCHEMY_TEMPLATES.foreign_key.safe_substitute(column_name=column_name,
                                                              column_type=column_type,
                                                              column_args=column_args,
                                                              foreign_key_args=reference,
                                                              type_params=type_params))
        join_string = "\n" + self.tab
        return join_string.join(res)
461802
private function getAllTableNames()
    {
        $handler = $this->databaseConnection->queryAndHandle("SHOW TABLES FROM `" . $this->databaseConnection->getDatabaseName() . "`");
        $tableNames = array();

        if ($handler->getResultSize() > 0) {
            while ($oDatabaseResultRow = $handler->fetchNextResultObject()) {
                $tablesInVariableName = "Tables_in_" . $this->databaseConnection->getDatabaseName();
                // add only tables with the current connection prefix
                if (
                    substr(
                        $oDatabaseResultRow->$tablesInVariableName,
                        0,
                        strlen($this->databaseConnection->getTablePrefix()))
                    == $this->databaseConnection->getTablePrefix()) {

                    array_push($tableNames, $oDatabaseResultRow->$tablesInVariableName);
                }

            }
        }

        return $tableNames;
    }
169028
def listTables(self, dbName=None):
        
        if dbName is None:
            dbName = self.currentDatabase()
        iter = self._jcatalog.listTables(dbName).toLocalIterator()
        tables = []
        while iter.hasNext():
            jtable = iter.next()
            tables.append(Table(
                name=jtable.name(),
                database=jtable.database(),
                description=jtable.description(),
                tableType=jtable.tableType(),
                isTemporary=jtable.isTemporary()))
        return tables
855760
def to_s
      parts = FIELDS.flat_map do |field|
        [dump_extra_diffs(field),
         dump_missing_diffs(field),
         dump_mismatch_diffs(field)]
      end

      [
        "Table #{@table_name} does not match the expected schema.\n\n",
        parts.compact.join("\n"),
        "\nYou may disable schema checks by passing :disable => true to model_",
        "schema or by setting the ENV variable #{DISABLE_MODEL_SCHEMA_KEY}=1.\n"
      ].join
    end
24992
private String buildTableName(Elements elementUtils, SQLiteDatabaseSchema schema) {
		tableName = getSimpleName();
		tableName = schema.classNameConverter.convert(tableName);

		String temp = AnnotationUtility.extractAsString(getElement(), BindSqlType.class, AnnotationAttributeType.NAME);
		if (StringUtils.hasText(temp)) {
			tableName = temp;
		}

		return tableName;

	}
584020
def clean_names(lines, ensure_unique_names=False, strip_prefix=False,
                make_database_safe=False):
    
    names = {}

    for row in lines:
        if strip_prefix:
            row['name'] = row['name'][row['name'].find('-') + 1:]

            if row['indexed_by'] is not None:
                row['indexed_by'] = row['indexed_by'][row['indexed_by'].find(
                    '-') + 1:]

        if ensure_unique_names:
            i = 1
            while (row['name'] if i == 1 else
                   row['name'] + "-" + str(i)) in names:
                i += 1

            names[row['name'] if i == 1 else row['name'] + "-" + str(i)] = 1

            if i > 1:
                row['name'] = row['name'] + "-" + str(i)

        if make_database_safe:
            row['name'] = row['name'].replace("-", "_")
    return lines
146729
public function table_full_name($table, $escaped=false)
	{
    if ( \is_string($table) && ($table = trim($table)) ){
      $mtable = explode(".", str_replace("`", "", $table));
      if ( \count($mtable) === 3 ){
        $db = trim($mtable[0]);
        $table = trim($mtable[1]);
      }
      else if ( \count($mtable) === 2 ){
        $db = trim($mtable[0]);
        $table = trim($mtable[1]);
      }
      else{
        $db = $this->db->current;
        $table = trim($mtable[0]);
      }
      if ( bbn\str::check_name($db,$table) ){
        return $escaped ? "`".$db."`.`".$table."`" : $db.".".$table;
      }
    }
		return false;
	}
1122837
def get_tables_for_bind(self, bind=None):
        """"""
        result = []
        for table in itervalues(self.Model.metadata.tables):
            if table.info.get('bind_key') == bind:
                result.append(table)
        return result
718148
private String getDbTableName(String schemaName) {
    Preconditions.checkArgument(schemaName.matches(".+_.+_.+"));
    return schemaName.replaceFirst("_", ".").substring(0, schemaName.lastIndexOf('_'));
  }
789797
public function table_name($table, $quoted = false)
    {
        // let plugins alter the table name (#1489837)
        $plugin = rcube::get_instance()->plugins->exec_hook('db_table_name', array('table' => $table));
        $table = $plugin['table'];

        // add prefix to the table name if configured
        if (($prefix = $this->options['table_prefix']) && strpos($table, $prefix) !== 0) {
            $table = $prefix . $table;
        }

        if ($quoted) {
            $table = $this->quote_identifier($table);
        }

        return $table;
    }