package org.beetl.sql.core.engine;

import org.beetl.core.tag.Tag;
import org.beetl.sql.core.ExecuteContext;
import org.beetl.sql.core.db.DBAutoGeneratedSql;
import org.beetl.sql.core.db.DBType;

import java.io.IOException;

public class PageQueryTag extends Tag {

	//Override
	@Override
	public void render() {
		Object o = ctx.getGlobal(DBAutoGeneratedSql.PAGE);
		if(o!=null) {
			try {
				ExecuteContext executeContext = (ExecuteContext)ctx.getGlobal("_executeContext");
				if(executeContext.sqlManager.getDbStyle().getDBType()== DBType.DB_TAOS){
					this.bw.writeString("count(1)");
				}else{
					this.bw.writeString("count(*)");
				}

			} catch (IOException e) {
				//不可能发生
				e.printStackTrace();
			}

		} else {
			this.doBodyRender();

		}
	}

}
