0.0.12:rebuild sql logic