Skip to content

Commit

Permalink
fix: add getDateFormat to Schema/Grammar
Browse files Browse the repository at this point in the history
  • Loading branch information
taka-oyama committed Aug 17, 2022
1 parent 2f43479 commit 43bffe6
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 9 deletions.
32 changes: 32 additions & 0 deletions src/Colopl/Spanner/Concerns/SharedGrammarCalls.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
/**
* Copyright 2019 Colopl Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

namespace Colopl\Spanner\Concerns;

use Illuminate\Database\Grammar;

trait SharedGrammarCalls
{
/**
* @see Grammar::getDateFormat()
* @see https://cloud.google.com/spanner/docs/data-types#time-zones
*/
public function getDateFormat()
{
return 'Y-m-d\TH:i:s.uP';
}
}
12 changes: 3 additions & 9 deletions src/Colopl/Spanner/Query/Grammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

namespace Colopl\Spanner\Query;

use Colopl\Spanner\Concerns\SharedGrammarCalls;
use Colopl\Spanner\Query\Builder as SpannerBuilder;
use Illuminate\Database\Query\Builder;
use Illuminate\Database\Query\Expression;
Expand All @@ -25,6 +26,8 @@

class Grammar extends BaseGrammar
{
use SharedGrammarCalls;

/**
* @inheritDoc
*/
Expand Down Expand Up @@ -86,15 +89,6 @@ protected function wrapValue($value)
return '`'.str_replace('`', '``', $value).'`';
}

/**
* @inheritDoc
* @see https://cloud.google.com/spanner/docs/data-types#time-zones
*/
public function getDateFormat()
{
return 'Y-m-d\TH:i:s.uP';
}

/**
* @inheritDoc
*/
Expand Down
3 changes: 3 additions & 0 deletions src/Colopl/Spanner/Schema/Grammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

namespace Colopl\Spanner\Schema;

use Colopl\Spanner\Concerns\SharedGrammarCalls;
use Illuminate\Database\Connection;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Schema\Grammars\Grammar as BaseGrammar;
Expand All @@ -25,6 +26,8 @@

class Grammar extends BaseGrammar
{
use SharedGrammarCalls;

/**
* The possible column modifiers.
*
Expand Down

0 comments on commit 43bffe6

Please sign in to comment.