# -*- coding: utf-8 -*-
"""The sql Query model class."""
import re

from build.lib.plasoscaffolder.model import sql_query_model


class SQLQueryModel(object):
  "A sql Query Model."

  def __init__(self, query: str, name: str, columns: []):
    """ initializes the sql Query model.

    Args:
      columns ([SQLColumns]): list of columns for the Query
      name (str): The Name of the Query.
      query (str): The SQL Query.
    """
    self._name = name
    self._query = query
    self._columns = columns

  @property
  def Name(self) -> str:
    """ the sql Query Name.

    Returns:
      (str): The Name of the sql Query parser row.
    """
    return self._name

  @property
  def Query(self) -> bool:
    """ the sql Query

    Returns:
      (str): The SQL Query.

    """
    return self._query

  @property
  def Columns(self) -> []:
      return self._columns

class SQLColumns(object):
  """class for columns of a sql Query"""

  def __init__(self, sql_column: str):
    """ initializes the sql column model.

    Args:
      sqlcolum (str): the column Name of the sql Query
    """
    self._sql_column = sql_column

  @property
  def SQLColumn(self) -> str:
    """the sql column

    Returns:
      (str): the column of the sql
    """
    return self._sql_column

  #TODO write test
  def ColumnAsSnakeCase(self) -> str:
    """sql column name to snake case

    Returns:
      (str): the column name from the sql in snake case 
    """
    return '_'.join(re.findall('[A-Z][a-z]*', self._sql_column.lower()))


@@ -65,69 +65,8 @@
 re%0A%0A
-from build.lib.plasoscaffolder.model import sql_query_model%0A%0A
 %0Acla
@@ -524,29 +524,27 @@
 urns:%0A      
-(
 str
-)
 : The Name o
@@ -683,21 +683,19 @@
 :%0A      
-(
 str
-)
 : The SQ
@@ -773,24 +773,112 @@
 f) -%3E %5B%5D:%0A  
+  %22%22%22the columns of the query%0A%0A    Returns:%0A      %5BSQLColumns%5D: list of columns%0A    %22%22%22%0A
     return s
@@ -891,16 +891,17 @@
 olumns%0A%0A
+%0A
 class SQ
@@ -1061,21 +1061,23 @@
      sql
+_
 colum
+n
  (str): 
@@ -1228,37 +1228,35 @@
  Returns:%0A      
-(
 str
-)
 : the column of 
@@ -1303,16 +1303,17 @@
 umn%0A%0A  #
+ 
 TODO wri
@@ -1415,21 +1415,19 @@
 :%0A      
-(
 str
-)
 : the co
@@ -1462,17 +1462,16 @@
 ake case
- 
 %0A    %22%22%22
@@ -1544,9 +1544,8 @@
 wer()))%0A
-%0A

correct some pylint errors