Check if a sequence exists

@return exists or not
354312
private static function _sequenceExists()
    {
        if (Driver::$primary_key_behaviour != Driver::PRIMARY_KEY_SEQUENCE) {
            return null;
        }

        // caching if the sequence exists
        $cls  = get_called_class();
        $name = self::resolveSequenceName();

        if (array_key_exists($cls, self::$_sequence_exists)
            && array_key_exists($name, self::$_sequence_exists[$cls])
        ) {
            return true;
        }

        $rtn = false;

        switch (Driver::$name) {
        case "oracle":
            $rtn = self::_oracleSequenceExists($name);
            break;
        case "postgresql":
            $rtn = self::_postgresqlSequenceExists($name);
            break;
        }

        // if exists, cache result
        if ($rtn) {
            if (!array_key_exists($cls, self::$_sequence_exists)) {
                self::$_sequence_exists[$cls] = array();
            }
            self::$_sequence_exists[$cls][$name] = true;
        }
        return $rtn;
    }
386068
public function exists()
    {
        $sql = $this->grammar->compileExists($this);

        $results = $this->connection->query($sql, $this->getBindings())->result();

        if (isset($results[0])) {
            $results = (array) $results[0];
            return (bool) $results['exists'];
        }
        return false;
    }
590392
public function exists(): bool
    {
        $key = $this->getStorageKey();

        return $key && $this->getFlexDirectory()->getStorage()->hasKey($key);
    }
1146431
def checkseq(sequence: str=None,  code="ATGC") -> bool:
    
    for base in sequence:
        if base not in code:
            return False
    return True
561576
public function exists()
    {
        foreach (func_get_args() as $value) {
            if (!in_array($value, $this->collection)) {
                return false;
            }
        }

        return true;
    }
765953
public static <T> boolean any(final Iterable<T> sequence,
                                  final Predicate<? super T> predicate) {
        for (T t : sequence) {
            if (predicate.test(t)) {
                return true;
            }
        }
        return false;
    }
1215288
public function checkDbTableExists() {
		$ds = $this->getDataSource();
		$existsTables = $ds->listSources();
		if (empty($existsTables)) {
			return false;
		}

		$schemaList = [];
		$schemaCheckingList = [''];
		$schemaCheckingListCfg = $this->_modelConfigInstaller->getListSchemaChecking();
		if (!empty($schemaCheckingList)) {
			$schemaCheckingList = array_merge($schemaCheckingList, $schemaCheckingListCfg);
		}
		foreach ($schemaCheckingList as $schemaCheckingListItem) {
			$name = null;
			$path = null;
			$file = null;
			$connection = null;
			$plugin = null;

			if (preg_match('/[\s\b]?\-\-name\s+(\w+)/', $schemaCheckingListItem, $matches) && (count($matches) == 2)) {
				list($plugin, $name) = pluginSplit($matches[1]);
			} elseif (preg_match('/^(\w+)/', $schemaCheckingListItem, $matches) && (count($matches) == 2)) {
				$name = $matches[1];
			}

			if (preg_match('/[\s\b]?(?:\-p|\-\-plugin)\s+(\w+)/', $schemaCheckingListItem, $matches) && (count($matches) == 2)) {
				$plugin = $matches[1];
			}

			if (preg_match('/[\s\b]?(?:\-c|\-\-connection)\s+(\w+)/', $schemaCheckingListItem, $matches) && (count($matches) == 2)) {
				$connection = $matches[1];
			}

			if (preg_match('/[\s\b]?\-\-path\s+(\w+)/', $schemaCheckingListItem, $matches) && (count($matches) == 2)) {
				$path = $matches[1];
			}

			if (preg_match('/[\s\b]?\-\-file\s+(\w+)/', $schemaCheckingListItem, $matches) && (count($matches) == 2)) {
				$file = $matches[1];
			}

			if (!empty($name)) {
				$file = Inflector::underscore($name);
			} elseif (empty($file)) {
				$file = 'schema.php';
			}

			if (strpos($file, '.php') === false) {
				$file .= '.php';
			}

			if (!empty($plugin) && empty($name)) {
				$name = $plugin;
			}

			$name = Inflector::camelize($name);
			$schemaList[] = compact('name', 'path', 'file', 'connection', 'plugin');
		}

		$existsTables = array_flip($existsTables);
		foreach ($schemaList as $schemaListItem) {
			$Schema = new CakeSchema($schemaListItem);
			$oldSchema = $Schema->load();
			if (!$oldSchema) {
				return false;
			}

			$diffTables = array_diff_key($oldSchema->tables, $existsTables);
			if (!empty($diffTables)) {
				return false;
			}
			unset($Schema);
		}

		return true;
	}
16434
public function keyExists($key)
    {
        $exists = true;
        try {
            $this->get($key);
        } catch (Exception $e) {
            $exists = false;
        }
        return $exists;
    }
115074
public static function typeExists()
    {
        $instance = new static;

        $params = $instance->getBasicEsParams();

        return $instance->getElasticSearchClient()->indices()->existsType($params);
    }
717070
public function exists()
    {
        $limit = $this->limit;

        $result = $this->limit(1)->count() > 0;

        $this->limit($limit);

        return $result;
    }
331059
public final void mEXISTS() throws RecognitionException {
		try {
			int _type = EXISTS;
			int _channel = DEFAULT_TOKEN_CHANNEL;
			// hql.g:26:8: ( 'exists' )
			// hql.g:26:10: 'exists'
			{
			match("exists"); if (state.failed) return;

			}

			state.type = _type;
			state.channel = _channel;
		}
		finally {
			// do for sure before leaving
		}
	}
1044066
public function fileExists()
    {
        $this->filenameIsValide($this->name);

        return file_exists($this->getPath()) || is_dir($this->base_dir."/".$this->name);
    }
879608
public function exists()
    {
        $quotedTable = \Database\DatabaseConnectionFactory::get()->quote($this->getTable());
        $record = \Database\DatabaseConnectionFactory::get()->query("show tables like {$quotedTable}");
        return !is_a($record, 'Database\DatabaseRecord\EmptyDatabaseRecord') && count($record->all()) > 0;
    }
1306460
public function exists()
    {
        return ($this->page_id > 0 || $this->file_id > 0 || $this->custom_url !== null
            || $this->shortcode !== null && $this->title !== null);
    }
76189
def check_seq_exists(self, seq, amount_ntermwildcards):
        
        cursor = self.get_cursor()
        if amount_ntermwildcards > 0:
            seq = seq[::-1]
            sqlseq = '{}{}'.format(seq, '%')
            # FIXME non-parametrized string binding because if ? binding is
            # used the INDEX is not used when looking up, apparently because
            # the query cant be optimized when using LIKE and binding.
            sql = ('select seqs from known_searchspace where seqs LIKE '
                   '"{}"'.format(sqlseq))
            for match in cursor.execute(sql):
                if match[0][:-amount_ntermwildcards] in seq:
                    return True
            return False
        else:
            sql = ('select exists(select seqs from known_searchspace '
                   'where seqs=? limit 1)')
            return cursor.execute(sql, (seq, )).fetchone()[0] == 1
607404
public function hasPrimaryKey()
    {
        if ($this->autoIncrement) {
            $empty = true;

            foreach ($this->keys as $key) {
                $empty = $empty && !$this->$key;
            }

            return !$empty;
        }

        $conditions = [];

        foreach ($this->getKeyName(true) as $key) {
            $conditions[$key] = $this->$key;
        }

        return $this->getDataMapper()->find($conditions);
    }
1035145
private function _postgresqlSequenceExists($name)
    {
        $escape = Driver::$escape_char;
        $sql    = "select count(*) as {$escape}CNT{$escape} from information_schema.sequences where sequence_name = '$name'";
        $stmt   = self::query($sql);
        $rst    = $stmt->fetch(\PDO::FETCH_ASSOC);
        $rtn    = intval($rst["CNT"]) > 0;
        self::closeCursor($stmt);
        return $rtn;
    }