diff --git a/src/NilPortugues/SqlQueryBuilder/Builder/GenericBuilder.php b/src/NilPortugues/SqlQueryBuilder/Builder/GenericBuilder.php index 9fac1e5..0293e0f 100644 --- a/src/NilPortugues/SqlQueryBuilder/Builder/GenericBuilder.php +++ b/src/NilPortugues/SqlQueryBuilder/Builder/GenericBuilder.php @@ -85,8 +85,6 @@ class GenericBuilder implements BuilderInterface public function __construct() { $this->placeholderWriter = WriterFactory::createPlaceholderWriter(); - - $this->sqlFormatter = new Formatter(); } /** @@ -255,6 +253,10 @@ public function write(QueryInterface $query, $resetPlaceholders = true) */ public function writeFormatted(QueryInterface $query) { + if (false === ($this->sqlFormatter instanceof Formatter)) { + $this->sqlFormatter = new Formatter(); + } + return $this->sqlFormatter->format($this->write($query)); }