Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timestamps randomly returned as strings #556

Open
shaneiseminger opened this issue Oct 28, 2016 · 2 comments
Open

Timestamps randomly returned as strings #556

shaneiseminger opened this issue Oct 28, 2016 · 2 comments

Comments

@shaneiseminger
Copy link
Contributor

I haven't been able to track down why, but over the past couple months we've seen instances where our timestamp columns aren't DateTime objects, but instead are strings. The occurrence so far seems to show up in random places.

@erkinsergey
Copy link

I encountered a similar problem while updating the library. Suddenly, my code began to throw an error that the date field is a string and not a DateTime object.

I remembered that the previous version was a bit fixed for me to work correctly with PostgreSql.
After transferring this fix, everything works correctly.
Perhaps the date fields remain strings due to some kind of hidden error.

My case is that the PostgreSQl adapter does not read the table structure that is outside the public schema. I fix the Table.php:

private function get_meta_data()
{
// as more adapters are added probably want to do this a better way
// than using instanceof but gud enuff for now
$quote_name = !($this->conn instanceof PgsqlAdapter);

  //$table_name = $this->get_fully_qualified_table_name($quote_name);
      $table_name = $this->get_fully_qualified_table_name_fix($quote_name);
  $conn = $this->conn;
  $this->columns = Cache::get("get_meta_data-$table_name", function() use ($conn,       $table_name) { return $conn->columns($table_name); });
}

and add in the same place:

public function get_fully_qualified_table_name_fix($quote_name=true)
{
$table = $quote_name ? $this->conn->quote_name($this->table) : $this->table;

/*if ($this->db_name)
	$table = $this->conn->quote_name($this->db_name) . ".$table";*/
return $table;

}

@erkinsergey
Copy link

Maybe this information will be useful to someone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants