<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "mybatis-3-mapper.dtd">
<mapper namespace="com.mortals.xhx.base.system.gentable.dao.ibatis.GentableColumnDaoImpl">


    <select id="selectDbTableColumnsByName" parameterType="String" resultMap="GentableColumnEntity-Map">
        SELECT
            column_name as columnName,
            column_default as defaultValue,
            ( CASE WHEN ( is_nullable = 'no' <![CDATA[ && ]]> column_key != 'PRI' ) THEN '1' ELSE '0' END ) AS isRequired,
            ( CASE WHEN column_key = 'PRI' THEN '1' ELSE '0' END ) AS isPrimaryKey,
            ordinal_position AS sort,
            column_comment AS columnComment,
            ( CASE WHEN extra = 'auto_increment' THEN '1' ELSE '0' END ) AS isIncrement,
            column_type AS columnType
        FROM
            information_schema.COLUMNS
        WHERE
            table_schema = ( SELECT DATABASE ( ) )
            AND table_name = #{tableName}
        ORDER BY
            ordinal_position
    </select>


</mapper>